Thread: Concatenate
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Concatenate

Thanks for the feedback.

Happy to hear you're sorted out.


Gord

On Tue, 9 Jan 2007 10:22:00 -0800, Wanna Learn
wrote:

Gord, Sorry I know what I was doing wrong. Again thanks this is a time saver
and definetly a keeper

"Gord Dibben" wrote:

You can use a macro or a User Defined Function.

Macro................

Sub ConCat_Cells()
Dim x As Range
Dim y As Range
Dim z As Range
Dim w As String
Dim sbuf As String
On Error GoTo endit
w = InputBox("Enter the Type of De-limiter Desired")
Set z = Application.InputBox("Select Destination Cell", _
"Destination Cell", , , , , , 8)
Application.SendKeys "+{F8}"
Set x = Application.InputBox("Select Cells...Contiguous or Non-Contiguous", _
"Cells Selection", , , , , , 8)
For Each y In x
If Len(y.text) 0 Then sbuf = sbuf & y.text & w
Next
z = Left(sbuf, Len(sbuf) - 1)
Exit Sub
endit:
MsgBox "Nothing Selected. Please try again."
End Sub

UDF..................

Function ConCatRange(CellBlock As Range) As String
Dim cell As Range
Dim sbuf As String
For Each cell In CellBlock
If Len(cell.text) 0 Then sbuf = sbuf & cell.text & ","
Next
ConCatRange = Left(sbuf, Len(sbuf) - 1)
End Function


Gord Dibben MS Excel MVP

On Tue, 9 Jan 2007 07:11:01 -0800, Wanna Learn
wrote:

Hello I have a list of numbers (exported from another application about 300
numbers) I have to create groups of numbers in one cell and each number
separated by a comma. Some groups have 20 numbers others 5 etc. I tried the
concatenante function with the "," between numbers take too long. Is there a
faster way to do this? thanks in advance