Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel (Un)Highlight Rows on Click

Status
Not open for further replies.

HProutt

Programmer
Oct 1, 2008
10
0
0
US
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.
 




Please post VBA question in Forum707.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top