MCONCAT with hyphenated numbers and a comma to separate

LoneScrunger

New Member
Joined
Feb 14, 2013
Messages
4
I'm trying to display hyphenated numbers in a range (e.g. 001-001-001 as one cell's contents) concatenated with a comma in between except the last number can't have a comma following it. I have a vertical array of these hyphenated numbers (Assessor Parcel Numbers that often start with a zero) and they are concatenated into one cell that is linked to a word document, so they can't end with a comma, however, I would like to include the whole range in the formula so that even if I have 1 or twenty APNs it will end without a comma on the last number. I know that if I designate the exact range each time then MCONCAT will not include a comma, but I don't know how to make it ignore all the blank cells.

I'm using =MCONCAT(AY146:AY174,", ") right now (that is the whole range).
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi
Welcome to the board

Instead of concatenating them with a comma, concatenate them with a space. This way you can use Trim() to get rid of multiple contiguous spaces and spaces at the beginning or at the end. You then just have to replace the spaces with the separator you want.

For ex., try:

=SUBSTITUTE(TRIM(MCONCAT(AY146:AY174," ") )," ",", ")
 
Last edited:
Upvote 0
Fantastic! Use trim to to remove the very last space and then apply the substitution. For a moment I was thinking that trim would remove all the spaces before and after each APN but after a little head scratching I see what is going on in the formula.

Thanks very much PGC! I've never used either of those functions before. :)
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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