I have a spreadsheet where I can click on any cell and the entire row will get highlighted in the color of my choice. For example, if I click on G10, all of row 10 will highlight in a light blue color. Now I want to be able to click anywhere in row 10 again and have the row go back to the original formatting.
Currently, my code looks like:
Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Static rr
Static cc
If cc <> "" Then
With Rows(rr).Interior
.ColorIndex = xlNone
End With
End If
r = Selection.Row
rr = r
With Rows(r).Interior
.ColorIndex = 37
.Pattern = xlSolid
End With
End Sub
It was taken from another blog and altered as best as I could so if there is a way to clean it up that makes sense I am open to it.
Currently, my code looks like:
Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Static rr
Static cc
If cc <> "" Then
With Rows(rr).Interior
.ColorIndex = xlNone
End With
End If
r = Selection.Row
rr = r
With Rows(r).Interior
.ColorIndex = 37
.Pattern = xlSolid
End With
End Sub
It was taken from another blog and altered as best as I could so if there is a way to clean it up that makes sense I am open to it.