I need to count the number of instances of a comma (,) in a

bab01824

Board Regular
Joined
Apr 10, 2003
Messages
53
I have a series of cells in column D with contents such as brkt123, nhma~3456, slm~4347,lgca~23456. I need to be able to put the substrings between commas into their own cells across a row. The length of each substring can vary, as well as the number of substrings.

My unelegant solution was to use LEFT to find the first one, and search within LEFT to identify the number of characters.
=LEFT(D1,SEARCH(",",D1)-1)

To find the second substring, I used MID like this;
=MID($D1,SEARCH(",",$D1,E1)+1,G1-E1-1)
where E1 is the result of SEARCH(",",D1), and G1 is the result of
=SEARCH(",",$D1,E1+1)

This works, but has a couple of faults or inefficiencies;
1) it requires a column (E1 & G1 in my example) just to store the position of the next comma, and
2) It does not work for the last substring in D1

Any advice?

:rolleyes:
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
highlight the column, go to data | text to columns, select delimited, hit next, select coma, hit finish.
 
Upvote 0
Re: I need to count the number of instances of a comma (,) i

Thanks Paddy. It must be too late for me to think clearly!
 
Upvote 0

Forum statistics

Threads
1,203,078
Messages
6,053,404
Members
444,662
Latest member
AaronPMH

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