jaydee
07-29-2015, 04:28 PM
Hi guys,
I have a pivot table with one column containing bank locations, and I want to highlight the row if the bank location is a certain number. I only know how to use the OR function in an if statement, but I have a total of 36 different banks that I want to highlight. Could someone help me write a better code?
The code so far looks like
Dim lastrow As Object
Dim irow As Long
Set lastrow = Range("a1").SpecialCells(xlCellTypeLastCell)
irow = lastrow.Row
For r = 1 To irow
If Cells(r, 1).Value = 5 Or Cells(r, 1).Value = 2 Then
Rows(r).EntireRow.Interior.ColorIndex = 35
End If
Next r
End Sub
Thank you in advance.
I have a pivot table with one column containing bank locations, and I want to highlight the row if the bank location is a certain number. I only know how to use the OR function in an if statement, but I have a total of 36 different banks that I want to highlight. Could someone help me write a better code?
The code so far looks like
Dim lastrow As Object
Dim irow As Long
Set lastrow = Range("a1").SpecialCells(xlCellTypeLastCell)
irow = lastrow.Row
For r = 1 To irow
If Cells(r, 1).Value = 5 Or Cells(r, 1).Value = 2 Then
Rows(r).EntireRow.Interior.ColorIndex = 35
End If
Next r
End Sub
Thank you in advance.