ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   creating a txt string from multiple cells separated by | symbol (https://www.excelbanter.com/excel-discussion-misc-queries/241842-creating-txt-string-multiple-cells-separated-%7C-symbol.html)

Pukeko47

creating a txt string from multiple cells separated by | symbol
 
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


JLatham

creating a txt string from multiple cells separated by | symbol
 
Define "smart". What are your rules for determining what is included in the
long text string and what isn't?

"Pukeko47" wrote:

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


Gord Dibben

creating a txt string from multiple cells separated by | symbol
 
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



On Sun, 6 Sep 2009 18:39:01 -0700, Pukeko47
wrote:

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




All times are GMT +1. The time now is 09:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com