PDA

View Full Version : Solved: Cells highlighted during selection.



aloy78
09-26-2011, 10:41 PM
Hi all,

I want an entire row to be highlighted when I click on a cell position. E.g. say I want to select and make changes on row 161. I want that entire row to be highlighted to yellow when I click on it or make changes to the cell content. After I'm done editing I want the entire row 161 to revert back to its original format. Thanks :)

mikerickson
09-26-2011, 11:33 PM
You could put this in the sheet's code module

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static Last As Range
If Not Last Is Nothing Then Last.Interior.ColorIndex = xlNone
With Target
If .Rows.Count = 1 Then
With Range(.Cells, Me.UsedRange)
With Application.Intersect(Target.EntireRow, .Cells)
.Interior.ColorIndex = 6
Set Last = .Cells
End With
End With
End If
End With
End Sub

aloy78
09-27-2011, 07:14 PM
You could put this in the sheet's code module

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static Last As Range
If Not Last Is Nothing Then Last.Interior.ColorIndex = xlNone
With Target
If .Rows.Count = 1 Then
With Range(.Cells, Me.UsedRange)
With Application.Intersect(Target.EntireRow, .Cells)
.Interior.ColorIndex = 6
Set Last = .Cells
End With
End With
End If
End With
End Sub


Works perfectly thanks :friends: