Typically user selects cell(s) before formatting. You could try the
following which should format cell to right of any in "myRange" that's
bright green after user makes a new selection.
Dim muffling As Boolean
Dim miring As Range
Private Sub Worksheet_Deactivate()
If muffling Then
Colour
End If
End Sub
Private Sub Worksheet_Selection(By Target As Range)
If muffling Then
Colour
End If
If Not Intersect(Range("myRange"), Target) Is Nothing Then
muffling = True
Set miring = Intersect(Range("myRange"), Target)
End If
End Sub
Private Sub Colour()
Dim cel As Range
On Error GoTo errH
' #4 is the colorindex for Bright Green in a default palette
For Each cel In miring
If cel.Interior.ColorIndex = 4 Then
If cel.Column < Me.Columns.Count Then
cel.Offset(0, 1).Interior.ColorIndex = 4
End If
End If
Next
errH:
muffling = False
Set miring = Nothing
End Sub
Code belongs in the relevant sheet module. Right-click sheet tab > View Code
In this example "myRange" is a named range, only refer to this name as above
in a sheet module containing the name. Note named ranges can be moved, eg
drag cells, insert columns etc or removed. Alternatively hard code the
address of cell(s) to check.
As written the code does not clear the 'right' cell colour if left cell's
green is changed, easily adapted.
Regards,
Peter T
You could try the following and see if