Tuesday, May 12, 2009

Excel Macros - Highlighting a Cell

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range)

Static OldRange As Range

On Error Resume Next

Target.Interior.ColorIndex = 4' Specify the number for colour

OldRange.Interior.ColorIndex = xlColorIndexNoneSet OldRange = TargetEnd Sub

No comments: