I have a code to change row colour based on number of days open in column E.
If 1 - 2 days it turns green, 3 -5 yellow, 6 to 50 red.
I now need code to change the row color based on colunm a Text. If CQMP change color as above.
If CQWR change color 1 to 15 Green, 16 to 25 yellow, 25 to 50 red.
Is this possible?
Sub Update_Row_Colors_Rev1()
''YOUR CODE "tstc"
Sheet1.Unprotect Password:="tstc"
Dim LRow As Integer
Dim LCell As String
Dim ICell As String
Dim LColorCells As String
'Start at row 8
LRow = 8
'Update row colors for the first 500 rows
While LRow < 100
LCell = "E" & LRow
ICell = "A" & LRow
'Color will changed in columns A to AR
LColorCells = "A" & LRow & ":" & "AR" & LRow
Select Case Left(Range(LCell)(ICell).Value, 6)
'Set row color to light green
Case "0", "1", "2"
Case "CQMP"
Rows(LRow & ":" & LRow).Select
Range(LColorCells).Interior.ColorIndex = 35
Range(LColorCells).Interior.Pattern = xlSolid
Selection.Font.Bold = True
Selection.Font.Color = RGB(0, 0, 0)
Else
Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15"
Case "CQWR"
Rows(LRow & ":" & LRow).Select
Range(LColorCells).Interior.ColorIndex = 35
Range(LColorCells).Interior.Pattern = xlSolid
Selection.Font.Bold = True
Selection.Font.Color = RGB(0, 0, 0)
'Set row color to light yellow
Case "3", "4", "5"
Rows(LRow & ":" & LRow).Select
Range(LColorCells).Interior.ColorIndex = 6
Range(LColorCells).Interior.Pattern = xlSolid
Selection.Font.Bold = True
Selection.Font.Color = RGB(0, 0, 0)
'Set row color to light red
Case "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", ";36", "37", "38", "39", "40", "41", ";42", "43", "44", "45", "46", "47", "48", "49", "50"
Rows(LRow & ":" & LRow).Select
Range(LColorCells).Interior.ColorIndex = 3
Range(LColorCells).Interior.Pattern = xlSolid
Selection.Font.Bold = True
Selection.Font.Color = RGB(255, 255, 255)
'Default all other rows to no color
Case Else
Rows(LRow & ":" & LRow).Select
Range(LColorCells).Interior.ColorIndex = 0
Selection.Font.Bold = False
Selection.Font.Color = RGB(0, 0, 0)
End Select
LRow = LRow + 1
Wend
Range("A1").Select
ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Select
Sheet1.Protect Password:="tstc", DrawingObjects:=False, _
contents:=True, Scenarios:=True, _
userinterfaceonly:=True, AllowFormattingCells:=True, AllowInsertingHyperlinks:=True, AllowFormattingRows:=True, AllowFormattingColumns:=True_
Sheet1.EnableAutoFilter = True
End Sub
If 1 - 2 days it turns green, 3 -5 yellow, 6 to 50 red.
I now need code to change the row color based on colunm a Text. If CQMP change color as above.
If CQWR change color 1 to 15 Green, 16 to 25 yellow, 25 to 50 red.
Is this possible?
Sub Update_Row_Colors_Rev1()
''YOUR CODE "tstc"
Sheet1.Unprotect Password:="tstc"
Dim LRow As Integer
Dim LCell As String
Dim ICell As String
Dim LColorCells As String
'Start at row 8
LRow = 8
'Update row colors for the first 500 rows
While LRow < 100
LCell = "E" & LRow
ICell = "A" & LRow
'Color will changed in columns A to AR
LColorCells = "A" & LRow & ":" & "AR" & LRow
Select Case Left(Range(LCell)(ICell).Value, 6)
'Set row color to light green
Case "0", "1", "2"
Case "CQMP"
Rows(LRow & ":" & LRow).Select
Range(LColorCells).Interior.ColorIndex = 35
Range(LColorCells).Interior.Pattern = xlSolid
Selection.Font.Bold = True
Selection.Font.Color = RGB(0, 0, 0)
Else
Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15"
Case "CQWR"
Rows(LRow & ":" & LRow).Select
Range(LColorCells).Interior.ColorIndex = 35
Range(LColorCells).Interior.Pattern = xlSolid
Selection.Font.Bold = True
Selection.Font.Color = RGB(0, 0, 0)
'Set row color to light yellow
Case "3", "4", "5"
Rows(LRow & ":" & LRow).Select
Range(LColorCells).Interior.ColorIndex = 6
Range(LColorCells).Interior.Pattern = xlSolid
Selection.Font.Bold = True
Selection.Font.Color = RGB(0, 0, 0)
'Set row color to light red
Case "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", ";36", "37", "38", "39", "40", "41", ";42", "43", "44", "45", "46", "47", "48", "49", "50"
Rows(LRow & ":" & LRow).Select
Range(LColorCells).Interior.ColorIndex = 3
Range(LColorCells).Interior.Pattern = xlSolid
Selection.Font.Bold = True
Selection.Font.Color = RGB(255, 255, 255)
'Default all other rows to no color
Case Else
Rows(LRow & ":" & LRow).Select
Range(LColorCells).Interior.ColorIndex = 0
Selection.Font.Bold = False
Selection.Font.Color = RGB(0, 0, 0)
End Select
LRow = LRow + 1
Wend
Range("A1").Select
ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Select
Sheet1.Protect Password:="tstc", DrawingObjects:=False, _
contents:=True, Scenarios:=True, _
userinterfaceonly:=True, AllowFormattingCells:=True, AllowInsertingHyperlinks:=True, AllowFormattingRows:=True, AllowFormattingColumns:=True_
Sheet1.EnableAutoFilter = True
End Sub