Hi everyone!
I'm a bit new using VBA and was wondering if anyone could help me out in this... I'll have a lot of this type of situation to put and am looking for the clearest way to write VBA to get this done.
Column C is the values in the list of B1 (in green).
I woule like to have that If B1 = C1, then D1 is in .interior.colorindex = 37
The thing is, A1:D5 is a named range ("CTB1_NSF")
How is it possible to have that? The coding below always puts D1:D2 in .ColorIndex 37 and I don't know why...
Thanks!
Private Sub Worksheet_Change(ByVal Target As Range)
With Range("CTB1_NSF_dernierterme")
If .Cells(1, 2).Value = "" Then .Cells(i, 4).Interior.ColorIndex = 2
If .Cells(1, 2) = Cells(1, 3) Then .Cells(1, 4).Interior.ColorIndex = 37
If .Cells(1, 2) = Cells(2, 3) Then .Cells(2, 4).Interior.ColorIndex = 37
If .Cells(1, 2) = Cells(3, 3) Then .Cells(3, 4).Interior.ColorIndex = 37
If .Cells(1, 2) = Cells(4, 3) Then .Cells(4, 4).Interior.ColorIndex = 37
If .Cells(1, 2) = Cells(5, 3) Then .Cells(5, 4).Interior.ColorIndex = 37
End With
End Sub
Bookmarks