RealThoughts
New Member
- Joined
- Nov 6, 2019
- Messages
- 4
Hi, I am fairly new to excel VBA and I have tried a bunch of different methods. I am trying to highlight only column I and J, if it is not blank, but also trying to highlight the cells with different colors based on values column G. For now, the code that I have inputted makes the excel change different colors while running and end end it with yellow. Any advice is helpful. Thank you.
Code:
Sub Color_non_blank_cells()
'declare variables
Dim ws As Worksheet
Dim ColorRng As Range
Dim CallStatus As Object
Set ws = Worksheets("Notifications")
Set ColorRng = ws.Range("I8:J14049")
'Set CallStatus = ws.Range("G8:G14049")
For Each CallStatus In ws.Range("G8:G14049")
If CallStatus = "Call Later" Then
ColorRng.Interior.Color = vbGreen
ElseIf CallStatus = "Voice Message" Then
ColorRng.Interior.Color = vbYellow
ElseIf CallStatus = "Automatic Message" Then
ColorRng.Interior.Color = vbRed
ElseIf CallStatus = "Will Revert Back" Then
ColorRng.Interior.Color = vbRed
ElseIf CallStatus = "No Response" Then
ColorRng.Interior.Color = vbRed
End If
Next CallStatus
'color non blank cells
'On Error Resume Next
'ColorRng.SpecialCells(xlCellTypeConstants).Interior.Color = RGB(87, 214, 42)
'ColorRng.SpecialCells(xlCellTypeFormulas).Interior.Color = RGB(87, 214, 42)
End Sub