Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 37
Default combining multiple columns using ", " seperations..

I apologize if this is a repeat.
I am trying to combine multiple columns with names in each into one column
with ", " separating the values. Issue being blank cells still returning ", "
between info

i.e. -
Jonathan, Douglas, David, , , ,
Joseph, , , , , ,
Samantha Nicole, Mathew Robert, , , , ,
, , , , , ,
Paige, Payton, , , , ,

Naturally I'd like to get rid of the extra comma's and spaces. Thoughts?

Formula currently used:
=I2&", "&J2&", "&K2&", "&L2&", "&M2&", "&N2&", "&O2
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default combining multiple columns using ", " seperations..

If there are no cells that have spaces in them (like "Jonathon Smith"), then you
could use:

=substitute(trim(i2&" "&j2&" "&k2&" "&l2&" "&m2&" "&n2&" "&o2)," ",", ")

Or you may want to use JE McGimpsey's UDF called MultiCat:
http://mcgimpsey.com/excel/udfs/multicat.html

With a minor tweak:

Public Function MultiCat( _
ByRef rRng As Excel.Range, _
Optional ByVal sDelim As String = "") _
As String
Dim rCell As Range
For Each rCell In rRng.Cells
if isempty(rcell.value) then
'skip it
else
MultiCat = MultiCat & sDelim & rCell.Text
end if
Next rCell
if multicat < "" then
MultiCat = Mid(MultiCat, Len(sDelim) + 1)
end if
End Function

If you're new to macros:

Debra Dalgleish has some notes how to implement macros he
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)

Short course:

Open your workbook.
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there.

Now go back to excel.
Into a test cell and type:
=multicat(i2:o2,", ")



Murph wrote:

I apologize if this is a repeat.
I am trying to combine multiple columns with names in each into one column
with ", " separating the values. Issue being blank cells still returning ", "
between info

i.e. -
Jonathan, Douglas, David, , , ,
Joseph, , , , , ,
Samantha Nicole, Mathew Robert, , , , ,
, , , , , ,
Paige, Payton, , , , ,

Naturally I'd like to get rid of the extra comma's and spaces. Thoughts?

Formula currently used:
=I2&", "&J2&", "&K2&", "&L2&", "&M2&", "&N2&", "&O2


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default combining multiple columns using ", " seperations..

=I2&", "&J2&", "&K2&", "&L2&", "&M2&", "&N2&", "&O2

As long as none of the referenced cells contain spaces and/or commas...

All on one line...

=SUBSTITUTE(TRIM(I2&" "&J2&" "
&K2&" "&L2&" "&M2&" "&N2
&" "&O2)," ",", ")

--
Biff
Microsoft Excel MVP


"Murph" wrote in message
...
I apologize if this is a repeat.
I am trying to combine multiple columns with names in each into one column
with ", " separating the values. Issue being blank cells still returning
", "
between info

i.e. -
Jonathan, Douglas, David, , , ,
Joseph, , , , , ,
Samantha Nicole, Mathew Robert, , , , ,
, , , , , ,
Paige, Payton, , , , ,

Naturally I'd like to get rid of the extra comma's and spaces. Thoughts?

Formula currently used:
=I2&", "&J2&", "&K2&", "&L2&", "&M2&", "&N2&", "&O2



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,718
Default combining multiple columns using ", " seperations..

=TRIM(SUBSTITUTE(SUBSTITUTE(CONCATENATE(I2,",",J2, ",",K2,",",L2,",",M2,",",N2,",",O2),",",", ")," ,",""))


"Murph" wrote:

I apologize if this is a repeat.
I am trying to combine multiple columns with names in each into one column
with ", " separating the values. Issue being blank cells still returning ", "
between info

i.e. -
Jonathan, Douglas, David, , , ,
Joseph, , , , , ,
Samantha Nicole, Mathew Robert, , , , ,
, , , , , ,
Paige, Payton, , , , ,

Naturally I'd like to get rid of the extra comma's and spaces. Thoughts?

Formula currently used:
=I2&", "&J2&", "&K2&", "&L2&", "&M2&", "&N2&", "&O2

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default combining multiple columns using ", " seperations..

=TRIM(SUBSTITUTE(SUBSTITUTE(CONCATENATE(I2,",",J2 ,",",K2,",",L2,",",M2,",",N2,",",O2),",",",
")," ,",""))


If the range is completely empty or if the last cell that contains an entry
is any cell other than O2 that formula returns a trailing comma.

I2 = X

Formula returns X,

--
Biff
Microsoft Excel MVP


"Teethless mama" wrote in message
...
=TRIM(SUBSTITUTE(SUBSTITUTE(CONCATENATE(I2,",",J2, ",",K2,",",L2,",",M2,",",N2,",",O2),",",",
")," ,",""))


"Murph" wrote:

I apologize if this is a repeat.
I am trying to combine multiple columns with names in each into one
column
with ", " separating the values. Issue being blank cells still returning
", "
between info

i.e. -
Jonathan, Douglas, David, , , ,
Joseph, , , , , ,
Samantha Nicole, Mathew Robert, , , , ,
, , , , , ,
Paige, Payton, , , , ,

Naturally I'd like to get rid of the extra comma's and spaces. Thoughts?

Formula currently used:
=I2&", "&J2&", "&K2&", "&L2&", "&M2&", "&N2&", "&O2





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining "IF"statement with "Vlookup" Malcolm McMaster[_2_] Excel Discussion (Misc queries) 9 October 21st 14 03:13 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
the "0" number is lost when combining multiple columns Hal Excel Worksheet Functions 5 January 26th 07 10:27 PM
Make pivot table with multiple "data" fields in columns not rows? cdomby Excel Discussion (Misc queries) 1 January 15th 07 04:54 PM
Combining formulas, "and" & "or" to verify content of multiple cel Shu of AZ Excel Discussion (Misc queries) 15 October 15th 06 11:22 PM


All times are GMT +1. The time now is 01:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"