Hi, I am a beginning in visual basic. What I am trying to do is whenever a box is clicked, highlight a specific range. Then, if another box is clicked after that, the previous range will unhighlight, and another range will highlight. Here is my code but it doesn't work right now.
Dim FSelect As Boolean
Dim myRange As Range
Sub Rectangle18_Click()
If FSelect Then
UnhighlightBox (myRange) <---error - runtime error "424" object required
End If
Range("C9:D9").Select
HighlightBox
FSelect = True
Set myRange = Range("C9:D9")
End Sub
Sub Rectangle19_Click()
If FSelect Then
UnhighlightBox (myRange)
End If
Range("C11:D11").Select
HighlightBox
FSelect = True
Set myRange = Range("C11:D11")
End Sub
Sub HighlightBox()
Selection.Interior.ColorIndex = 36
End Sub
Sub UnhighlightBox(cellRng As Range)
cellRng.Interior.ColorIndex = 2
End Sub