VBA question - I am trying to execute this code when I enter my excel SHEET
Here is my VBA CODE:
'CODE to Turn TIES to YELLOW'
Private Sub Workbook_Open()
Dim lr As Long, i As Long, clr As Long
clr = 6
Sheet3.Activate
Sheet3.Cells.Interior.Color = xlNone
lr = Cells(Rows.Count, "A").End(xlUp).Row
lr = lr - 2
For i = 4 To lr Step 6
If Cells(i, 3) = Cells(i, 7) And Cells(i, 3) = Cells(i, 11) Then
Cells(i, 3).Interior.ColorIndex = clr
Cells(i, 7).Interior.ColorIndex = clr
Cells(i, 11).Interior.ColorIndex = clr
ElseIf Cells(i, 3) = Cells(i, 7) Then
Cells(i, 3).Interior.ColorIndex = clr
Cells(i, 7).Interior.ColorIndex = clr
ElseIf Cells(i, 3) = Cells(i, 11) Then
Cells(i, 3).Interior.ColorIndex = clr
Cells(i, 11).Interior.ColorIndex = clr
ElseIf Cells(i, 7) = Cells(i, 11) Then
Cells(i, 7).Interior.ColorIndex = clr
Cells(i, 11).Interior.ColorIndex = clr
End If
Next i
End Sub
Here is my VBA CODE:
'CODE to Turn TIES to YELLOW'
Private Sub Workbook_Open()
Dim lr As Long, i As Long, clr As Long
clr = 6
Sheet3.Activate
Sheet3.Cells.Interior.Color = xlNone
lr = Cells(Rows.Count, "A").End(xlUp).Row
lr = lr - 2
For i = 4 To lr Step 6
If Cells(i, 3) = Cells(i, 7) And Cells(i, 3) = Cells(i, 11) Then
Cells(i, 3).Interior.ColorIndex = clr
Cells(i, 7).Interior.ColorIndex = clr
Cells(i, 11).Interior.ColorIndex = clr
ElseIf Cells(i, 3) = Cells(i, 7) Then
Cells(i, 3).Interior.ColorIndex = clr
Cells(i, 7).Interior.ColorIndex = clr
ElseIf Cells(i, 3) = Cells(i, 11) Then
Cells(i, 3).Interior.ColorIndex = clr
Cells(i, 11).Interior.ColorIndex = clr
ElseIf Cells(i, 7) = Cells(i, 11) Then
Cells(i, 7).Interior.ColorIndex = clr
Cells(i, 11).Interior.ColorIndex = clr
End If
Next i
End Sub