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

What does your original data look like?

307051 in one cell and 20940 in another?

Will return 307051,20940

Or are the numbers in 4 separate cells?

Will return 30,705,120,940


Gord

On Tue, 9 Jan 2007 10:14:01 -0800, Wanna Learn
wrote:

Thanks Gord
This is excellent. I 'm doing something wrong .....
This is my answer 30,705,120,949 it should read 307051,20940 thanks

"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