Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I highlight the active cell in a spreadsheet?
I want the active cell to change color.
|
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I highlight the active cell in a spreadsheet?
Hi, CW,
Try pasting this into the code window of the worksheet for which you want to highlight the active cell. Change the "22" value in the sixth line to change the colour of the highlight. Hope this helps Pete Private Sub Worksheet_SelectionChange(ByVal Target As Range) Cells.FormatConditions.Delete With Target .FormatConditions.Delete .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE" .FormatConditions(1).Interior.ColorIndex = 22 End With End Sub "CW" wrote: I want the active cell to change color. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I highlight the active cell in a spreadsheet?
Hi, The below is also pasted into the worksheet's code, but this allow for any conditional formatting etc that already exists on the sheet to be returned after the active cell is changed rather than deleted as Pete's option does with "Cells.FormatConditions.Delete". Check out the link below for further info/instructions. Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) 'sourced from http://www.mcgimpsey.com/excel/highl...iteRetainColor Const cnNUMCOLS As Long = 10 'if this is 256 it is all columns but macro is slower Const cnHIGHLIGHTCOLOR As Long = 36 'default lt. yellow Static rOld As Range Static nColorIndices(1 To cnNUMCOLS) As Long Dim i As Long If Not rOld Is Nothing Then 'Restore color indices With rOld.Cells If .Row = ActiveCell.Row Then Exit Sub 'same row, don't restore For i = 1 To cnNUMCOLS ..Item(i).Interior.ColorIndex = nColorIndices(i) Next i End With End If Set rOld = Cells(ActiveCell.Row, 1).Resize(1, cnNUMCOLS) With rOld For i = 1 To cnNUMCOLS nColorIndices(i) = .Item(i).Interior.ColorIndex Next i ..Interior.ColorIndex = cnHIGHLIGHTCOLOR End With End Sub Hth, Rob Brockett NZ Always learning & the best way to learn is to experience... -- broro183 ------------------------------------------------------------------------ broro183's Profile: http://www.excelforum.com/member.php...o&userid=30068 View this thread: http://www.excelforum.com/showthread...hreadid=520284 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Row select mode to highlight active row of active cell | Excel Discussion (Misc queries) | |||
How do I get row and column of active cell to highlight? | Excel Discussion (Misc queries) | |||
Active Cell Highlight | Excel Discussion (Misc queries) | |||
Active cell highlight | Excel Discussion (Misc queries) | |||
Highlight Active Cell | Excel Discussion (Misc queries) |