Count comma as zero if there is no comma in a cell

Zaimon

New Member
Joined
Sep 10, 2024
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi guys,

Here is my formula: =LEN(W3)-LEN(SUBSTITUTE(W3, ",",""))+1

Is there is a way to change the values from 1 to 0 since there is no comma at all in the selected Cell.

Thanks,

1726222798834.png
 
Hello, how about:

=IF(OR(ISBLANK(W3),LEN(W3)-LEN(SUBSTITUTE(W3, ",",""))=0),0,LEN(W3)-LEN(SUBSTITUTE(W3, ",",""))+1)
 
Last edited:
Upvote 1
What version of Excel are you using?

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’)
 
Upvote 1
Another option:
Excel Formula:
=IF(ISNUMBER(SEARCH(",",W3)),LEN(W3)-LEN(SUBSTITUTE(W3, ",",""))+1,0)
 
Upvote 1
Would this work?:

Excel Formula:
=LEN(W3)-LEN(SUBSTITUTE(W3, ",",""))

or

Excel Formula:
=LEN(W3)-LEN(SUBSTITUTE(W3, ",",""))+(W3<>"")
 
Upvote 1
Solution

Forum statistics

Threads
1,226,848
Messages
6,193,318
Members
453,790
Latest member
yassinosnoo1

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