I've created a code to color rows based on a condition. However I can't seem to get the coding right to only look at a row if there is data in Column I. Right now it checks every row up until 20,000.
Any help simplifying would be greatly appreciated.
Sub Color()
Dim LRow As Integer<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
Dim LCell As String<o></o>
Dim LColorCells As String<o></o>
'Start at row 2<o></o>
LRow = 2<o></o>
'Update row colors for the first 20000 rows<o></o>
While LRow < 20000<o></o>
LCell = "I" & LRow<o></o>
'Color will changed in columns A to U<o></o>
LColorCells = "A" & LRow & ":" & "U" & LRow<o></o>
Select Case Left(Range(LCell).Value, 6)<o></o>
'Set row color to light purple<o></o>
Case "A"<o></o>
Range(LColorCells).Interior.ColorIndex = 7<o></o>
Range(LColorCells).Interior.Pattern = xlSolid<o></o>
'Set row color to light yellow<o></o>
Case "AM"<o></o>
Rows(LRow & ":" & LRow).Select<o></o>
Range(LColorCells).Interior.ColorIndex = 44<o></o>
Range(LColorCells).Interior.Pattern = xlSolid<o></o>
End Select<o></o>
LRow = LRow + 1<o></o>
Wend<o></o>
Range("A1").Select<o></o>
End Sub
Any help simplifying would be greatly appreciated.
Sub Color()
Dim LRow As Integer<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
Dim LCell As String<o></o>
Dim LColorCells As String<o></o>
'Start at row 2<o></o>
LRow = 2<o></o>
'Update row colors for the first 20000 rows<o></o>
While LRow < 20000<o></o>
LCell = "I" & LRow<o></o>
'Color will changed in columns A to U<o></o>
LColorCells = "A" & LRow & ":" & "U" & LRow<o></o>
Select Case Left(Range(LCell).Value, 6)<o></o>
'Set row color to light purple<o></o>
Case "A"<o></o>
Range(LColorCells).Interior.ColorIndex = 7<o></o>
Range(LColorCells).Interior.Pattern = xlSolid<o></o>
'Set row color to light yellow<o></o>
Case "AM"<o></o>
Rows(LRow & ":" & LRow).Select<o></o>
Range(LColorCells).Interior.ColorIndex = 44<o></o>
Range(LColorCells).Interior.Pattern = xlSolid<o></o>
End Select<o></o>
LRow = LRow + 1<o></o>
Wend<o></o>
Range("A1").Select<o></o>
End Sub