AshRhazaly
New member
- Joined
- Jul 19, 2016
- Messages
- 9
- Reaction score
- 0
- Points
- 0
Hi gurus,
I've an issue with my code and I'm fairly new to VBA so pardon any amateurish mistakes.
If a cell in Overextension returns a "Yes", the code will then search the price column for the maximum value.
I'm facing a compile error "End if without block if" and curious to know what the solution is.
I've an issue with my code and I'm fairly new to VBA so pardon any amateurish mistakes.
If a cell in Overextension returns a "Yes", the code will then search the price column for the maximum value.
I'm facing a compile error "End if without block if" and curious to know what the solution is.
Code:
Private Sub CommandButton1_Click()
Dim maximum As Double, OEResult As Range, OverExtension As Range, PriceNo As Range, PriceCol As Range, OEYes As Range
Cells.Interior.ColorIndex = 0
Set PriceCol = Range("C2:C12")
Set OverExtension = Range("D2:D11")
Set OEYes = Union(OEYes, OEResult)
OEYes = OEResult
maximum = WorksheetFunction.Max(OEYes)
For Each OEResult In OverExtension
If OEResult.Value = "Yes" Then
For Each PriceNo In PriceCol
If PriceNo.Value = maximum Then PriceNo.Cells.Interior.ColorIndex = 22
End If
End If
Next PriceNo
Next OEResult
End Sub