Number of values seperated by commas in a cell

Ghris

Board Regular
Joined
Mar 17, 2012
Messages
73
Heya,

I got a problem to solve: In my cell (O5) I have an amount of numbers, separated by commas and spaces. I wish to know the amount of numbers in that cell.
For example: This is in O5: "1, 3, 8, 12, 15, 16" (without the "") And i need something that tells me that there are 6 values/numbers in there.

Restrictions:
Doesn't matter if its VBA or a formula tells me that. But preferably I don't want to use a text to columns macro. Also preferably not with variables, as I will count the amount of values in that cell thousands of times.

Kind regards,

Chris
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
How about

Excel 2012
AB
1, 3, 8, 12, 15, 16

<COLGROUP><COL style="BACKGROUND-COLOR: #dae7f5"><COL><COL></COLGROUP><THEAD>
</THEAD><TBODY>
[TD="align: center"]1[/TD]

[TD="align: right"]6[/TD]

</TBODY>
Sheet1

[TABLE="width: 85%"]
<TBODY>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<THEAD>[TR="bgcolor: #dae7f5"]
[TH="width: 10"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</THEAD><TBODY>[TR]
[TH="width: 10, bgcolor: #dae7f5"]B1[/TH]
[TD="align: left"]=LEN(A1)-LEN(SUBSTITUTE(A1,",",""))+1[/TD]
[/TR]
</TBODY>[/TABLE]
[/TD]
[/TR]
</TBODY>[/TABLE]
 
Upvote 0
Hmm, both the same answer, but it doesn't seem to work. Excel gives me an error, he thinks im not trying to type a formula. It knows LEN function tho... weird
 
Upvote 0
Tried copying and typing. Both give this error:

243kb28.jpg


My actual cell for checking is S9 instead of O5 But that can't be the problem I assume.

Edit: this is what insert function gives as invalid: S9,",",""
 
Upvote 0
It works perfectly happily here

Excel Workbook
QRS
971, 3, 8, 12, 15, 16, 23
Sheet6
 
Upvote 0
Perhaps you need to use semicolons instead of commans?

=LEN(S9)-LEN(SUBSTITUTE(S9;",";""))+1
 
Upvote 0
Doh! Jonmo1 is right on the semicolons. Thanks all for the help! Much appreciated. Must be something regional?
 
Upvote 0
Glad to help.

Yes, it's a regional setting called the "List Seperator". Found in Windows Control Panel - Region And Language - Additional Settings.
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

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