Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming,microsoft.public.excel.misc
|
|||
|
|||
![]()
Thought I'd tag this.
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim iColor As Integer '// Note: Don't use if you have conditional '// formatting that you want to keep '// On error resume in case user selects a range of cells On Error Resume Next iColor = Target.Interior.ColorIndex '// Leave On Error ON for Row offset errors If iColor < 0 Then iColor = 36 Else iColor = iColor + 1 End If '// Need this test in case Font color is the same If iColor = Target.Font.ColorIndex Then iColor = iColor + 1 Cells.FormatConditions.Delete '// Horizontal color banding With Range("A" & Target.Row, Target.Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:="TRUE" .FormatConditions(1).Interior.ColorIndex = iColor End With '// Vertical color banding With Range(Target.Offset(1 - Target.Row, 0).Address & ":" & _ Target.Offset(-1, 0).Address) 'Rows(Target.Row) .FormatConditions.Add Type:=2, Formula1:="TRUE" .FormatConditions(1).Interior.ColorIndex = iColor End With End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
detect ctrl-c was pressed (in copy mode) from vba? | Excel Discussion (Misc queries) | |||
detect ctrl-c was pressed (in copy mode) from vba? | Excel Programming | |||
detect ctrl-c was pressed (in copy mode) from vba? | Excel Programming | |||
always the specific control has focus when F3 or Ctrl+q is pressed | Excel Programming | |||
how to detect mouse pressed(down) event for work sheet | Excel Programming |