creating a txt string from multiple cells separated by | symbol

  • Thread starter Thread starter Pukeko47
  • Start date Start date
P

Pukeko47

Trying to create a very long txt string from hundreds of separate cells so I
can import into another program.
This needs to be smart as I need to do this operation often
 
Define "smart". What are your rules for determining what is included in the
long text string and what isn't?
 
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) - Len(w))
Exit Sub
endit:
MsgBox "Nothing Selected. Please try again."
End Sub



Gord Dibben MS Excel MVP
 
Back
Top