Macro to highlight rows based on cell value

paul_sykes00

Board Regular
Joined
May 7, 2012
Messages
53
Hi, Hope someone can help with the below,

I have a table of data on sheet 1. Column A is Name.

I am looking for a macro that will highlight the rows with certain names a specific colour.

Thanks in advance, Paul
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Code:
Sub Maybe()
Dim c As Range
	For Each c In Range("A2:A" & Cells(Rows.Count, 1).End(xlUp).Row)
		If c.Value = "Whatever" Then c.Interior.ColorIndex = 45
	Next c
End Sub
 
Upvote 0
Great Thanks, Just one small thing. It currently only highlights the cell in column A, How do I highlight the full row?
 
Upvote 0
Change this
Code:
Then c.Interior.ColorIndex = 45
to this
Code:
c.EntireRow.Interior.ColorIndex = 45
 
Upvote 0

Forum statistics

Threads
1,215,746
Messages
6,126,650
Members
449,326
Latest member
asp123

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