A Working IF Statement that I cannot adapt for Conditional Formatting

netrixuser

Board Regular
Joined
Jan 21, 2019
Messages
77
Office Version
  1. 365
Platform
  1. Windows
Hello all,

My goal is to highlight a row of cells where one cell in that row contains more than 4 commas.

I started with this IF just to prove the logic and it returns TRUE
Excel Formula:
=IF(E37="",0,LEN(E37)-LEN(SUBSTITUTE(E37,",","")))>4

My Conditional Format Formula currently looks like this - but it does nothing. Even though cell E37 contains 12 commas
Excel Formula:
="IF(E37="""",0,LEN(E37)-LEN(SUBSTITUTE(E37,"","","""")))>4"

Am I doing something obviously wrong - or is there an easier way to achieve my goal of highlighting a row if one cell in that row contains more than 4 commas ?

Any help very much appreciated.

Regards

Netrix
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
There should not be quotes after the = sign or at the end of the formula. That makes it a text string.
 
Upvote 0
What version of excel are you using?
Are you counting commas in text, formulas, or both?
 
Upvote 0
Is this what you are trying to achieve -

Book1
ABC
1Try, Some, thing, different, to, surprise5Test
2Try,Some,thing,different,to,surprise5Test
3Try, Some, thing, different, to, surprise5Test
40Test
5Try, Some, thing2Test
6Try, Some, thing, different, to, surpriseTest
7Try, Some, thing, different,4Test
Sheet1
Cell Formulas
RangeFormula
B1:B5,B7B1=LEN(A1)-LEN(SUBSTITUTE(A1,",",""))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A1:C7Expression=AND($A1<>"",LEN($A1)-LEN(SUBSTITUTE($A1,",",""))>4)textNO
 
Upvote 0
There should not be quotes after the = sign or at the end of the formula. That makes it a text string.
Hi RoryA - Thank you for your reply,
I changed the Condition Format formula to =IF(E37="""",0,LEN(E37)-LEN(SUBSTITUTE(E37,"","","""")))>4 but it made no difference.
 
Upvote 0
Its Office 365

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

For conditional formatting you can use
Excel Formula:
=LEN(E37)-LEN(SUBSTITUTE(E37,",",""))>4
 
Upvote 0
Is this what you are trying to achieve -

Book1
ABC
1Try, Some, thing, different, to, surprise5Test
2Try,Some,thing,different,to,surprise5Test
3Try, Some, thing, different, to, surprise5Test
40Test
5Try, Some, thing2Test
6Try, Some, thing, different, to, surpriseTest
7Try, Some, thing, different,4Test
Sheet1
Cell Formulas
RangeFormula
B1:B5,B7B1=LEN(A1)-LEN(SUBSTITUTE(A1,",",""))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A1:C7Expression=AND($A1<>"",LEN($A1)-LEN(SUBSTITUTE($A1,",",""))>4)textNO
Thank you for this, SanjayGMusafir,

That was what I was looking for, although I could not get it work as I wanted.
I moved on slightly in my "wants" to try and write the Conditional Format written into some VBA code, I that has been successful - I'm sure I must have had a typo when trying to use CF in Excel !!

Thanks again.
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

For conditional formatting you can use
Excel Formula:
=LEN(E37)-LEN(SUBSTITUTE(E37,",",""))>4
Thanks for this Fluff,

I have updated my profile info.
As per my reply above, my "wants" changed slightly but with yours and SanjayGMusafir's help I am sorted..... for now !!

Kind regards
 
Upvote 0
Glad you sorted it & thanks for letting us know.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,179
Members
453,021
Latest member
Justyna P

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