MS Excel/O365 - Count comma-separated numbers in range

elmerg

New Member
Joined
Jun 24, 2008
Messages
21
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello everyone. Need some help with an Excel counting function; I figured it would be simple, but apparently it's not.

I need a total count of the numeric values in a column; some of the cells will have comma-separated entries, some will have single numerical entries, and some will have words.

For an example of data:
-
No data
85, 93
100
85, 86
No data
No data
100
92, 0
95

I need to count ONLY the numbers, including any zeroes, leaving out anything that is non-numeric. Some numbers may be repeated within the same cells. I also cannot separate out the numbers due to data organization needs.

So if I was counting the above example, my count output would be 9.

Any assistance would be appreciated.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I suggest that you update your Account details (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’)

If you have textjoin maybe (dependant on version this may need array entry)
+Fluff 1.xlsm
ABC
14-9
15No data
1685, 93
17100
1885, 86
19
20No data
21100
2292, 0
2395
24
Main
Cell Formulas
RangeFormula
C14C14=COUNT(FILTERXML("<o><m>"&TEXTJOIN("</m><m>",,SUBSTITUTE(A14:A23,",","</m><m>"))&"</m></o>","//m"))
 
Upvote 0
Solution
Thank you, I will do the update to my profile.

And thank you again, that worked perfectly for what I needed..

Would you also have thoughts on how to alter that to count only the single zeroes?

So if counting the above example, we would just have a result of 1.
 
Upvote 0
If you have the new LET function try
Excel Formula:
=LET(xml,FILTERXML("<o><m>"&TEXTJOIN("</m><m>",,SUBSTITUTE(A14:A23,",","</m><m>"))&"</m></o>","//m"),COUNT(FILTER(xml,xml=0)))
 
Upvote 0
If you have the new LET function try
Excel Formula:
=LET(xml,FILTERXML("<o><m>"&TEXTJOIN("</m><m>",,SUBSTITUTE(A14:A23,",","</m><m>"))&"</m></o>","//m"),COUNT(FILTER(xml,xml=0)))

Thank you for the input. I do not have the let() function in the version of Excel I have access to for this project.
 
Upvote 0
Ok, not a problem, just means a slightly longer formula
Excel Formula:
=COUNT(FILTER(FILTERXML("<o><m>"&TEXTJOIN("</m><m>",,SUBSTITUTE(A14:A23,",","</m><m>"))&"</m></o>","//m"),FILTERXML("<o><m>"&TEXTJOIN("</m><m>",,SUBSTITUTE(A14:A23,",","</m><m>"))&"</m></o>","//m")=0))
 
Upvote 0
Ok, not a problem, just means a slightly longer formula
Excel Formula:
=COUNT(FILTER(FILTERXML("<o><m>"&TEXTJOIN("</m><m>",,SUBSTITUTE(A14:A23,",","</m><m>"))&"</m></o>","//m"),FILTERXML("<o><m>"&TEXTJOIN("</m><m>",,SUBSTITUTE(A14:A23,",","</m><m>"))&"</m></o>","//m")=0))

Amazing. thank you so much. I'm working from a 'light to moderate use' Excel need, so something like this is a bit beyond my current knowledge for it. So I appreciate the help. I will also dig into these new functions you've used here, so I can better understand how they work in the future. Many thanks!
 
Upvote 0
You're welcome & thanks for the feedback.
 
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’)

Just change the =0 to <>0
 
Upvote 0

Forum statistics

Threads
1,214,992
Messages
6,122,631
Members
449,095
Latest member
bsb1122

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