Jaye Cavallo
New Member
- Joined
- Mar 10, 2022
- Messages
- 45
- Office Version
- 2016
- Platform
- Windows
Hello,
I am searching for an Excel VBA solution that would accomplish the following:
I have data in 60 rows in columns A through Z, with the value of column P either "Access" "Noise" or "Notification" and the value of column Q as "open" or "closed". How can I write a VBA loop whereby if P="access" and Q="open" then B through Z has an interior color (NOT formatconditions) set to 26? I want to avoid using VBA Conditional Formatting. My data is contained in A2:Z60 (Named range is Data), column P is a Named range of Reason and column Q is status.
I am searching for a solution that is similar to this code used elsewhere in the worksheet, but code with multiple conditions, if true, change the interior color in multiple cells in a given row.
Dim My_Range As Range
Set My_Range = Worksheets("Customer_Interactions").Range("A2:A3569")
For Each cell In My_Range
If cell.Value Like "Electric" Then
cell.Interior.ColorIndex = 22
ElseIf cell.Value Like "Gas" Then
cell.Interior.ColorIndex = 36
ElseIf cell.Value Like "Other - Specify in Notes" Then
cell.Interior.ColorIndex = 15
Else
cell.Interior.ColorIndex = xlNone
End If
Next
I am searching for an Excel VBA solution that would accomplish the following:
I have data in 60 rows in columns A through Z, with the value of column P either "Access" "Noise" or "Notification" and the value of column Q as "open" or "closed". How can I write a VBA loop whereby if P="access" and Q="open" then B through Z has an interior color (NOT formatconditions) set to 26? I want to avoid using VBA Conditional Formatting. My data is contained in A2:Z60 (Named range is Data), column P is a Named range of Reason and column Q is status.
I am searching for a solution that is similar to this code used elsewhere in the worksheet, but code with multiple conditions, if true, change the interior color in multiple cells in a given row.
Dim My_Range As Range
Set My_Range = Worksheets("Customer_Interactions").Range("A2:A3569")
For Each cell In My_Range
If cell.Value Like "Electric" Then
cell.Interior.ColorIndex = 22
ElseIf cell.Value Like "Gas" Then
cell.Interior.ColorIndex = 36
ElseIf cell.Value Like "Other - Specify in Notes" Then
cell.Interior.ColorIndex = 15
Else
cell.Interior.ColorIndex = xlNone
End If
Next