Conditional formating question

Polanskiman

Board Regular
Joined
Nov 29, 2011
Messages
119
Office Version
  1. 365
  2. 2016
  3. 2011
  4. 2010
  5. 2007
Platform
  1. Windows
  2. MacOS
  3. Mobile
I have this rather complex file but I simplified my issue by making a mock up on a new file to ask the question here. So here is the deal.

Sheet 1. I have this list of products in that specific order. When a product is selected with 'x' then the amount shows up.
Book1.xlsx
CDE
4ProductSelectedAmount
5product 4x1
6product 20
7product 3x1
8product 160
9product 50
10product 90
11product 12x1
12product 110
13product 10
14product 130
15product 10x1
16product 150
17product 14x1
Sheet1
Cell Formulas
RangeFormula
E5:E17E5=IF(D5="x",1,0)


Sheet 2. This is the cost sheet. Products are in that specific order and some products are not in Sheet 1 (for instance product 6, 7 and 8). You can see both sheets have different product orders. That's the way it is and cannot be changed.
Book1.xlsx
CDEF
2ProductAmountUnit priceCost
3product 1050
4product 2020
5product 3166
6product 4155
7product 5010
8product 6---
9product 7---
10product 8---
11product 9020
12product 10166
13product 11080
14product 12199
15product 13010
16product 14144
17product 15020
18product 16060
Sheet2
Cell Formulas
RangeFormula
D3D3=Sheet1!E13
D4:D5,D7D4=Sheet1!E6
D6,D11,D13,D15,D17D6=Sheet1!E5
F3:F7,F11:F18F3=D3*E3
D12D12=Sheet1!E15
D14D14=Sheet1!E11
D16D16=Sheet1!E17
D18D18=Sheet1!E8


What I need is for products in Sheet 2 to be highlighted when there is an amount for that product. I have manually highlighted the cells for your understanding. Now, I know this can very easily be done by doing 1 conditional formating for each and every product/line but I would rather have only 1 conditional formating rule for the whole list that could do the job. The idea is to have the least amount of Conditional formating rules are possible.

How can this be achieved and if possible without the need of a helper column?

Thank you.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
What about this?

Polanskiman.xlsm
CDEF
2ProductAmountUnit priceCost
3product 1050
4product 2020
5product 3166
6product 4155
7product 5010
8product 6---
9product 7---
10product 8---
11product 9020
12product 10166
13product 11080
14product 12199
15product 13010
16product 14144
17product 15020
18product 16060
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D3:F18Expression=AND($D3<>0,$D3<>"-")textNO
 
Upvote 0
Solution
Oh boy... That was pathetically easy ?. Shame on me.
Thank you Peter. You're the best!
 
Upvote 0
You're welcome. Thanks for the follow-up. (y)

No shame - it is what the forum is for. :)

BTW, here is an even simpler way. ?

Polanskiman.xlsm
CDEF
2ProductAmountUnit priceCost
3product 1050
4product 2020
5product 3166
6product 4155
7product 5010
8product 6---
9product 7---
10product 8---
11product 9020
12product 10166
13product 11080
14product 12199
15product 13010
16product 14144
17product 15020
18product 16060
Sheet2 (2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D3:F18Expression=-$D3textNO
 
Last edited:
Upvote 0
That's an interesting one. Can you explain why adding a minus to the reference makes this work?
 
Upvote 0
Can you explain why adding a minus to the reference makes this work?
CF formats the cell if the condition is True and does not if the condition is False, or an Error occurs. Excel treats the number zero as a False and any other number (positive or negative) as True.
So,
- for the zero cells -0 =0 so that is a False -> no format applied
- for any other numerical value (yours are all 1) the minus in front just 'swaps' the number from plus to minus or vice-versa but it will still be a non-zero value which counts as True -> format is applied
- for the "-" cells (or any other text) putting a minus in front results in an error since the numerical 'swap' cannot be done -> no format applied
 
Upvote 0

Forum statistics

Threads
1,214,608
Messages
6,120,500
Members
448,968
Latest member
screechyboy79

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