Option Explicit
Sub highlight_cells()
Dim lRow As Long, i
lRow = Cells(Rows.Count, 1).End(xlUp).Row ' last row in column A
Range("A2:BH" & lRow).Interior.Color = xlNone
'AssetCondition = P
'ReviseRUL = AP
'RULCalculated = AQ
'RULOverride = AR
'Priority = R
'Level5 = J
'YearinService = T
'EUL = AT
'UnitCost = L
'Manufacturer = Y
'CapacityUnitOfMeasure = X
'PlanType = Q
'YearManufactured = AJ
For i = 2 To lRow
'1
If InStr(Cells(i, "P"), "Good") And Cells(i, "AP") = 0 And Cells(i, "AQ") <= 10 Then
Range("P" & i & "," & "AP" & i & "," & "AQ" & i).Interior.ColorIndex = 33
End If
'2
If InStr(Cells(i, "P"), "Good") And Cells(i, "AP") = 1 And Cells(i, "AR") <= 10 Then
Range("P" & i & "," & "AP" & i & "," & "AR" & i).Interior.ColorIndex = 36
End If
'3
If InStr(Cells(i, "R"), "Priority 1") Then
If Not InStr(Cells(i, "J"), "UPS") Then
If Not InStr(Cells(i, "J"), "Emergency") Then
If Not InStr(Cells(i, "J"), "Fire") Then
If Not InStr(Cells(i, "J"), "Annunciation") Then
If Not InStr(Cells(i, "J"), "Generator") Then
If Not InStr(Cells(i, "J"), "Sprinkler") Then
Range("R" & i & "," & "J" & i).Interior.ColorIndex = 40
End If
End If
End If
End If
End If
End If
End If
'4
If Cells(i, "T") = "" Then GoTo Five 'if blank assuming the rows column AQ and AT are blank also
If IsNumeric(Cells(i, "AQ")) Then Cells(i, "AQ") = Cells(i, "AQ") * 1 'converted to num since stored as text
If IsNumeric(Cells(i, "T")) Then Cells(i, "T") = Cells(i, "T") * 1 'converted to num since stored as text
If IsNumeric(Cells(i, "AT")) Then Cells(i, "AT") = Cells(i, "AT") * 1 'converted to num since stored as text
If Cells(i, "AQ") <> Cells(i, "T") + Cells(i, "AT") - Year(Date) Then
Range("AQ" & i & "," & "T" & i & "," & "AT" & i).Interior.ColorIndex = 43
End If
'5
Five:
If Cells(i, "L") = "" Then Cells(i, "L").Interior.ColorIndex = 4
'6
If Cells(i, "Y") = "" Then Cells(i, "Y") = "Not Visible"
'7
If IsNumeric(Cells(i, "X")) Then Cells(i, "X").Interior.ColorIndex = 44
'8
Cells(i, "Q") = UCase(Cells(i, "Q"))
'9
If InStr(Cells(i, "AJ"), ",") Then Cells(i, "AJ").Interior.ColorIndex = 50
Next i
End Sub
Bookmarks