Conditional Formatting not working as it should - logic wrong?

saraapple

Board Regular
Joined
Feb 3, 2020
Messages
165
Office Version
  1. 2010
Platform
  1. Windows
I am having a nightmare with what should be a straight forward task.
I have created two conditional formatting rules - which work (they change colour) but it makes no sense as to why?

These are the formulas:

Delivery Schedule TEMPLATE UPDATED 210221.xlsm
K
2KIRKCALDY
Delivery Schedule Stoke
Cells with Conditional Formatting
CellConditionCell FormatStop If True
K2:V101Expression=COUNTIF(OUTPUT!K:V,Suppliers)>0textNO
K2:V101Expression=AND(K2<>"",MATCH($K2,SALVAGE,0))textNO


I want them to look at two lists I have created "Salvage" and "Suppliers" then flag them in the colours.
Excel accepts the formulas but all the cells end up formatted wrong, so Kirkcaldy is not on the suppliers list so should not be in red type.

Am I missing something obvious as I have been working on this for hours and getting nowhere!

Thank you for taking the time to look
Sara
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Why have you chosen two different formulas to express similar things? Your countif formula looks to be the wrong way round, you'd want to look for K2 in Suppliers I think? You could use that same formula in the Salvage conditional format

Excel Formula:
=COUNTIF(Suppliers,K2)>0

Excel Formula:
=COUNTIF(Salvage,K2)>0

The other thing is to make sure that you are in the top cell of your list (K2) when you type in the formula, or it tends to go wrong.

They'll be dancing in the streets of Raith if you manage to get it to work (for any residents of Kirkcaldy looking in).
 
Upvote 0
Solution
How about
Excel Formula:
=COUNTIF(Suppliers,$K2)>0
 
Upvote 0
Getting there....
I used the formulas you both suggested with a little change to ignore the blank cells as follows:
Delivery Schedule TEMPLATE UPDATED 210221 (Autosaved).xlsm
K
2KIRKCALDY
Delivery Schedule Stoke
Cells with Conditional Formatting
CellConditionCell FormatStop If True
K2:V101Expression=COUNTIF(Suppliers,$K2)>0textNO
K2:V101Expression=AND(K2<>"",(COUNTIF(SALVAGE,$K2)>0))textNO


Suppliers has failed to turn any cells to red type.
Salvage has filled in the stores green on the salvage list correctly with the exception of two cells which turn green despite them not being on the list?!?!

Any ideas?
 
Upvote 0
I hadn't noticed that the CF was looking at a range of columns so you need to remove the $ sign
 
Upvote 0
If you try typing in the formula into the next available column in the same row as your data and see if it works correctly. If so, copy that formula into the conditional formatting, making sure you select the full range (K2:V101), but still have K2 as the "current" (white) cell.
Also, you shouldn't need the and condition in the second expression. Unless you have a Salvage list that has a bunch of blanks in it?
 
Upvote 0
Perfect!
Thank you both for your assistance, and thank you [U]RicoS[/U] for the tip on checking the formula as the data rather than going straight for conditional formatting :)
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,780
Messages
6,121,525
Members
449,037
Latest member
tmmotairi

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