So I have a data file that includes the postcodes of supporters and I need to highlight the rows that contain a number of them. At the moment I have the following code;
Sub ScotTest()
Dim iLastRow As Long
Dim i As Long
iLastRow = Cells(Rows.Count, "F").End(xlUp).Row
For i = iLastRow To 1 Step -1
If Cells(i, "H").Text Like "TD" & "*" Then
Rows(i).Interior.ColorIndex = 4
End If
Next i
End Sub
Whilst this highlights the correct rows with all postcodes beginning with TD I now need to also highlight postcodes beginning with KY and KA.
Thanks
Simply adding an OR to your IF should do the trick :)
Sub ScotTest()
Dim iLastRow As Long
Dim i As Long
iLastRow = Cells(Rows.Count, "F").End(xlUp).Row
For i = iLastRow To 1 Step -1
If Cells(i, "H").Text Like "TD" & "*" OR _
Cells(i, "H").Text Like "KY" & "*" OR _
Cells(i, "H").Text Like "KA" & "*" Then
Rows(i).Interior.ColorIndex = 4
End If
Next i
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With