View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.newusers
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default CONCATENATE on separated values

The CONCATENATE function can add separators between cell references

=CONCATENATE(D2,",",C10,",",C14,",",E12)

Or a macro which allows you to select non-contiguous cells and entert the
separator you want.

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


Gord Dibben MS Excel MVP

On Wed, 15 Aug 2007 14:02:20 -0700, wrote:

I would like to know how I can take different cells (non concurrent)
and string them together in another cell with separators. The
CONCATENATE function can't do this. The end result that I am looking
for is to select a number of cells using a userform and listbox with
checkboxes, and have all of those values combine and be pasted into a
cell of my choosing. I have the userform, the listbox, and the
checkboxes (courtesy of John Walkenbach's book), I need to figure out
how to combine my selections into a single cell.

Thanks for your reponses in advance.

Shane