Michael M
Well-known Member
- Joined
- Oct 27, 2005
- Messages
- 21,589
- Office Version
-
- 365
- 2019
- 2013
- 2007
- Platform
-
- Windows
Hi All
I copied this code from one of Bills Links, but it refuses to work.
It gives an object required error from the second line.
Any clues ??
Regards
Michael M
I copied this code from one of Bills Links, but it refuses to work.
It gives an object required error from the second line.
Any clues ??
Regards
Michael M
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim IColor As Integer
On Error Resume Next
IColor = Target.Interior.ColorIndex
If IColor < 0 Then
IColor = 36
Else
IColor = IColor + 1
End If
If IColor = Target.Font.ColorIndex Then IColor = IColor + 1
Cells.FormatConditions.Delete
With Range("A" & Target.Row, Target.Address)
.FormatConditions.Add Type:=2, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = IColor
End With
With Range(Target.Offset(1 - Target.Row, 0).Address & ":" & _
Target.Offset(-1, 0).Address)
.FormatConditions.Add Type:=2, Formula1:="true"
.FormatConditions(1).Interior.ColorIndex = IColor
End With
End Sub
Last edited by a moderator: