Highlight Values in Range without Loop

mExd2014

New Member
Joined
Dec 30, 2014
Messages
39
Hi all

I wonder if anyone can help.

I have some data with set headers. I want to highlight cells greater than zero in a particular column referencing its header (as the column is not always in a fixed position). However I also want to exclude entries if the adjacent column includes a particular reference.

Example - Column I = "Amount", column E = "Comments".

If the amount column has values greater than zero, I want to highlight these cells but only if the comments column does not contain the word 'exclude'.

Now I can do this with a for each loop using the Appliation.WorksheetFunction.Match formula to locate the headers and then highlight the cells however the loop is cumbersome.

Is there a better alternative?

Many thanks for any comments or points in the right direction.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
I used conditional formatting, where the data is in columns A-O and the comments could be anywhere in there, and the "Amount" could be anywhere in there.

MrExcelPlayground7.xlsx
ABCDEFGHIJKLMNO
1AmountCommentsAmount
22okay12
3-515
44okay-10
54Exclude this15
65-10
75exclude30
8-10-15
95okay50
10
11
12
13
14
Sheet14
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:O20Expression=AND(SUM(IF(ISERR(SEARCH("exclude",LOWER($A2:$O2))),0,1))=0,IF(A$1="Amount",TRUE,FALSE),A2>0)textNO
 
Upvote 0
Problem for me is my headings are not always in the same column to use conditional formatting.

Is there a way via VBA to sort the referenced column and then highlight values above zero I wonder
 
Upvote 0
Any column will work. In A-O in my example, but that can be easily changed to A-ZZ or whatever. As long as the header is in Row 1.
 
Upvote 0
Sorry I should have stated that I want it automated so that my macro is summing the total of the cells whilst simultaneously highlighting the values too. The first part is fine, its just whether I can highlight the cells without looping as there can be quite a few cells in the range.

Appreciate the conditional format option but the problem is my Amount column is not fixed in each worksheet so would need to amend the conditional formatting each time.
 
Upvote 0
I have the whole wide range conditionally formatted. But the formula ignores highlighting if the top of the column doesn't say "Amount". You might make a formula that does the conditional totalling too.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
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