VBA - Highlight a row if values in 2 columns meet certain criteria

jasonleewkd

New Member
Joined
Apr 3, 2012
Messages
10
Hello everyone! I'm trying to code out the following, but finding it difficult to

Search through the entire column M and N, and if value in column M is "Q3" and value in column N is "2014", then highlight in Green that row but only column A to DD.

For example, if M1 = "Q3" and N1 = "2014", then highlight in green A1:DD1.

Not so experienced with IF statements in VBA so any help is appreciated! Thanks.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Code:
if range("M1")="Q3" and range("N1")=2014 then range("A1:DD1").interior.colorindex=4

assume 2014 is a number and not text
 
Upvote 0
.
.

You don't need VBA to achieve this.

Apply a conditional formatting rule to cells A1:DD1 with the formula:

=AND($M$1=$Q$3,$N$1=2014)
 
Upvote 0

Forum statistics

Threads
1,215,836
Messages
6,127,173
Members
449,368
Latest member
JayHo

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