HOW TO CHANGE ROW COLOUR

  • Thread starter Thread starter adeel via OfficeKB.com
  • Start date Start date
A

adeel via OfficeKB.com

I want that current row colour with its header change, when i move to nex the
previous row change to default. is it possible.
 
Put the following in the Worksheet coding area:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlNone
Target.EntireRow.Interior.ColorIndex = 6
End Sub

as you navagate with either mouse click or arrow key, the selected row will
be hight-lighted.
 
Just as long as OP is aware that this will wipe out any currently colored cell
formatting on the sheet.


Gord Dibben MS Excel MVP
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
With Target.EntireRow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.Color Index = 6
End With

End Sub
 
Spell checker may have changed. Use this

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
With Target.EntireRow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 20
End With

End Sub
 
Back
Top