VBA - Highlight cell if greater or less than in dynamic range

Maleko-1

New Member
Joined
Oct 20, 2010
Messages
27
Hi there,
I can't find an answer to this in VBA.

Cell D5 has a value (upper limit) and cell D6 has a value (lower limit).
From D10 down to the end of data in column D are values that if falls outside of the upper and lower limit above I need the cell highlighted red.
Another catch is...I need the same scenario to happen in all other columns to the right that has data.
For example, E5 and E6 (upper and lower limits) and E10 down has the data and so on to the last column that has data.

If anyone can help me with this it would be so appreciated and I would forever be in debt to you. :)

Thank you
Marc
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
conditional formatting would be best no? apply the below rule to D10:Z1000 or however many cols/rows you have


=OR(D10<D$6,D10>D$5)<d$6,d10><d$6,d10></d$6,d10></d$6,d10>
 
Last edited:
Upvote 0
=OR(D10<D$6,D10>D$5)

something wrong. this should be the rule
 
Upvote 0
=OR(D10 <D$6 ,D10 > D$5)

have to use spaces for some reason
 
Upvote 0
right this page has something wrong with it

OR(D10<D$6,D10>D$5)
 
Upvote 0
=OR(D10 less than symbol D$6,D10 greater than symbol D$5)
 
Upvote 0
Thanks for the reply, but I need to use VBA.
I would use conditional format except that the workbook is generated by a macro and every time the code is run a new workbook is created.
 
Upvote 0
Can't write the code from my phone but why not record the conditional formatting rule and add it to the code you have?
 
Upvote 0
Still not having any luck. I know how to apply this to the first column I just don't know how to apply it to all the columns if they have data.
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,499
Members
449,089
Latest member
Raviguru

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