Background fill based on multiple text criteria

Barb Mick

New Member
Joined
Jan 25, 2018
Messages
14
Office Version
  1. 365
2/28/18Inv DateDue DateInv #AmountDays
Adams2/21/183/23/1850401889389.527
Adams2/15/183/17/1850401382220.9813
Adams2/15/183/17/1850401391505.7213
Bixly2/26/183/28/1850402231166.002
Bixly2/26/183/28/1850402211166.002
Cash2/26/183/28/1850402226548.092
Cash2/26/183/28/18504018521320.962
Davidson2/14/183/16/18504010415984.0114
Davidson02/21/183/23/18504010316609.327

<tbody>
</tbody>

I'm looking for vba code to highlight (preferably background color but text color is ok) all occurrences of certain names in column A in a list like this.
I have about 30 different names to search for and my list is generally about 1200 rows. Also, I don't want to do a list box, it's always the same names.

I don't think this should be as difficult as I seem to be making it.
Can anyone help?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
hi,

Heres a bit of code I have used for a while, it will only colour the row to the last column and not the entire row.

I have quickly put in the VB colours, but you can change these to be RGB values instead.

Code:
Sub colourrowtest()
    Dim c As Range
    Dim lastcol As Integer
    Dim lastRow As Long
    
lastRow = Cells(Rows.Count, "A").End(xlUp).Row
lastcol = Cells(1, Columns.Count).End(xlToLeft).Column

 For Each c In Range("A2:A" & lastRow)
    If c.Value = "Adams" Then
Range(Cells(c.Row, 1), Cells(c.Row, lastcol)).Interior.Color = vbRed
    ElseIf c.Value = "Davidson" Then
Range(Cells(c.Row, 1), Cells(c.Row, lastcol)).Interior.Color = vbGreen
    ElseIf c.Value = "Bixly" Then
Range(Cells(c.Row, 1), Cells(c.Row, lastcol)).Interior.Color = vbYellow
    End If

Next

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top