Conditional formatting - Count the number of cells in a row

louisli_evo

New Member
Joined
Mar 11, 2020
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Hi, I'm modifying an old worksheet to add an ability to check if some data throughout 12 months of a year has been correctly filled. I have verified the condition on separate cells but seems conditional formatting doesn't read the same formula syntax.

Sheet "Figures":
1669703539604.png

For example, if the frequency is "Annually", then it checks cells F2-Q2 if one of the cells is filled (or if eleven (11) hyphens "-" are left). If the frequency is quarterly, it checks cells F2-Q2 if four of the cells are filled (or if eight (8) hyphens "-" are left). If this condition is true, the background of "Frequency" changes to "no colour".

I applied conditional formatting on this "Frequency" column (D), with the formula:
="COUNTIF(F2:Q2,"-")==VLOOKUP('Figures'!D2,'(Controls)'!A2:C5,3)"

The Frequency on this sheet is just a reference to another cell in the sheet "Figures".
=Metrics!G2

And the Frequency on "Metrics" sheet has the following options (using data validation, from a list on sheet "(Controls)")
- Annually
- Biannually
- Quarterly
- Monthly
So, this is what I put on sheet "(Controls")
1669704618635.png


Did I miss anything? It seems close but I just couldn't figure out what's the problem.
Thank you very much.
 

Attachments

  • 1669703146616.png
    1669703146616.png
    4.9 KB · Views: 5

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
=VLOOKUP(D2,Controls!$A$2:$C$5,3,0)=SUMPRODUCT(--ISTEXT(F2:Q2))
 

Attachments

  • wwe.PNG
    wwe.PNG
    29.5 KB · Views: 3
Upvote 0
If the cells that are filled in are filled with numbers, then COUNT would be a simple function to use to check

louisli_evo.xlsm
DEFGHIJKLMNOPQ
1
2Annually------6-----
3Biannually--6---------
4Monthly243654567897
5Quarterly--4--4--3--2
Figures
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D2:D5Expression=COUNT(F2:Q2)=VLOOKUP(D2,'(Controls)'!A$2:B$5,2,0)textNO


If the non-dash cells are, or could be, text then tidying up your attempted CF formula above would be ..
- You had two = signs together in the middle of your formula
- Your formula was enclosed with double-quote marks
- Your range in the Controls sheet needs $ signs to anchor the rows A$2:C$5
- the VOLOOKUP function is missing the 4th argument of ",0"
- It is not a good idea to use the sheet name of the sheet the formula is used in within the formula (eg 'Figures')

louisli_evo.xlsm
DEFGHIJKLMNOPQ
1
2Annually------x-----
3Biannually--y---------
4Monthly24365d567897
5Quarterly--y--x--w--y
Figures (2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D2:D5Expression=COUNTIF(F2:Q2,"-")=VLOOKUP(D2,'(Controls)'!A$2:C$5,3,0)textNO
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,142
Members
452,892
Latest member
JUSTOUTOFMYREACH

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