Background fill based on multiple text criteria

Barb Mick

New Member
Joined
Jan 25, 2018
Messages
14
Office Version
  1. 365
[TABLE="width: 500"]
<tbody>[TR]
[TD]2/28/18[/TD]
[TD]Inv Date[/TD]
[TD]Due Date[/TD]
[TD]Inv #[/TD]
[TD]Amount[/TD]
[TD]Days[/TD]
[/TR]
[TR]
[TD]Adams[/TD]
[TD]2/21/18[/TD]
[TD]3/23/18[/TD]
[TD]5040188[/TD]
[TD]9389.52[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]Adams[/TD]
[TD]2/15/18[/TD]
[TD]3/17/18[/TD]
[TD]5040138[/TD]
[TD]2220.98[/TD]
[TD]13[/TD]
[/TR]
[TR]
[TD]Adams[/TD]
[TD]2/15/18[/TD]
[TD]3/17/18[/TD]
[TD]5040139[/TD]
[TD]1505.72[/TD]
[TD]13[/TD]
[/TR]
[TR]
[TD]Bixly[/TD]
[TD]2/26/18[/TD]
[TD]3/28/18[/TD]
[TD]5040223[/TD]
[TD]1166.00[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]Bixly[/TD]
[TD]2/26/18[/TD]
[TD]3/28/18[/TD]
[TD]5040221[/TD]
[TD]1166.00[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]Cash[/TD]
[TD]2/26/18[/TD]
[TD]3/28/18[/TD]
[TD]5040222[/TD]
[TD]6548.09[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]Cash[/TD]
[TD]2/26/18[/TD]
[TD]3/28/18[/TD]
[TD]5040185[/TD]
[TD]21320.96[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]Davidson[/TD]
[TD]2/14/18[/TD]
[TD]3/16/18[/TD]
[TD]5040104[/TD]
[TD]15984.01[/TD]
[TD]14[/TD]
[/TR]
[TR]
[TD]Davidson[/TD]
[TD]02/21/18[/TD]
[TD]3/23/18[/TD]
[TD]5040103[/TD]
[TD]16609.32[/TD]
[TD]7[/TD]
[/TR]
</tbody>[/TABLE]

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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
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,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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