A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Concatenate lists



 
 
Thread Tools Display Modes
  #1  
Old April 21st, 2010, 01:52 PM posted to microsoft.public.excel.misc
Hanspeter
external usenet poster
 
Posts: 1
Default Concatenate lists

Is there an Easier way to Concatenate a number of cells greater than 50 cells
in once cell without using A1&"_"&A2&"_"& and so on.

HAns
  #2  
Old April 21st, 2010, 02:18 PM posted to microsoft.public.excel.misc
Jarek Kujawa[_2_]
external usenet poster
 
Posts: 775
Default Concatenate lists

don't know how to populate 1 cell

but with your in A1:A50

in B1 insert = A1&"_"
in B2 insert = B1&A2&"_"

then drag/copy down


On 21 Kwi, 14:52, Hanspeter
wrote:
Is there an Easier way to Concatenate a number of cells greater than 50 cells
in once cell without using A1&"_"&A2&"_"& and so on.

HAns


  #3  
Old April 21st, 2010, 02:22 PM posted to microsoft.public.excel.misc
Luke M[_4_]
external usenet poster
 
Posts: 451
Default Concatenate lists

My suggestion would be to use an UDF. I think sooner or later, everyone
eventually realizes the need for something like this. This function will
concatenate every cell within a selected range, and you can choose what your
delimiter looks like. Install this into a Module in VBA.

'=========
Function ConcMe(r As Range, Optional x As String = ", ") As String
For Each c In r
'If cell is blank, don't include
If c.Value = "" Then GoTo NoInclude
ConcMe = ConcMe & c.Value & x
NoInclude:
Next c
'Remove final delimiter
ConcMe = Left(ConcMe, Len(ConcMe) - Len(x))
End Function
'==========

Then, back in your workbook, the formula is:
=ConcMe(A1:A50,"_")

--
Best Regards,

Luke M
"Hanspeter" wrote in message
...
Is there an Easier way to Concatenate a number of cells greater than 50
cells
in once cell without using A1&"_"&A2&"_"& and so on.

HAns



  #4  
Old April 21st, 2010, 02:26 PM posted to microsoft.public.excel.misc
Jacob Skaria
external usenet poster
 
Posts: 5,952
Default Concatenate lists

You will have to use a UDF (User Defined function). From workbook launch VBE
using Alt+F11. From menu Insert a Module and paste the below function.Close
and get back to workbook and try the below formula.

Syntax:
=CONCATRANGE(rngRange,strDelimiter,blnIgnoreBlank)
rngRange is the Range
strDelimiter Optional . Default is space
blnIgnoreBlank Optional. Default is False

Examples:
'1. Concatenate with default delimiter(space)
=CONCATRANGE(A1:A10)

'2. Concatenate with semicolon as delimiter and ignore blanks
=CONCATRANGE(A1:A10,":",1)

Function CONCATRANGE(rngRange As Range, _
Optional strDelimiter As String = " ", _
Optional blnIgnoreBlank As Boolean = False)
Dim varTemp As Range
For Each varTemp In rngRange
If blnIgnoreBlank Then
If Trim(varTemp) vbNullString Then _
CONCATRANGE = CONCATRANGE & strDelimiter & varTemp
Else
CONCATRANGE = CONCATRANGE & strDelimiter & varTemp
End If
Next
CONCATRANGE = WorksheetFunction.Trim(Mid(CONCATRANGE, _
len(strDelimiter)+1))
End Function

--
Jacob (MVP - Excel)


"Hanspeter" wrote:

Is there an Easier way to Concatenate a number of cells greater than 50 cells
in once cell without using A1&"_"&A2&"_"& and so on.

HAns

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


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


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.