Forum Discussion
Luiz_Martins_86
May 30, 2022Copper Contributor
VBA statement with a IF
Hi everyone, i not a advanced in VBA on excel and i need your help. I need to create a if statement that, when a colunm called "Last update time", have more then 30 days, the interior color of this...
- May 30, 2022
Sub color() Dim i As Integer Range("D:D").Interior.ColorIndex = 0 For i = 2 To 27 If Cells(i, 4).Value < Date - 60 And Cells(i, 5) <> "specific group" Then Cells(i, 4).Interior.ColorIndex = 3 Else If Cells(i, 4).Value < Date - 30 And Cells(i, 5) <> "specific group" Then Cells(i, 4).Interior.ColorIndex = 6 Else End If End If Next i End SubMaybe with these lines of code. In the attached file you can click the button in cell H2 to start the macro.
OliverScheurich
May 30, 2022Gold Contributor
Sub color()
Dim i As Integer
Range("D:D").Interior.ColorIndex = 0
For i = 2 To 27
If Cells(i, 4).Value < Date - 60 And Cells(i, 5) <> "specific group" Then
Cells(i, 4).Interior.ColorIndex = 3
Else
If Cells(i, 4).Value < Date - 30 And Cells(i, 5) <> "specific group" Then
Cells(i, 4).Interior.ColorIndex = 6
Else
End If
End If
Next i
End SubMaybe with these lines of code. In the attached file you can click the button in cell H2 to start the macro.
Luiz_Martins_86
May 31, 2022Copper Contributor
THank you for this!
This is help me a lot in my day-to-day!
This is help me a lot in my day-to-day!