Hello, I am trying to format the cells with the same color, but I do not know what is wrong with this.
Place the code in the sheet event to run automatically when the background is changed
VBA Code:
Sub RowFormat()
Dim LastCellColor As Long
Dim A As Range
For Each A In Range("a3:m100")
If Not IsError(A) Then
If A.Interior.ColorIndex <> xlNone Then
LastCellColor = A.Interior.Color
A.Offset(0, 9).Interior.ColorIndex = LastCellColor
Else
A.Offset(0, 9).Interior.ColorIndex = xlNone
End If
End If
Next A
End Sub
Place the code in the sheet event to run automatically when the background is changed