Concatenation Question

J

Jay

Hi,

I have 100 row, single column list of text strings. I am wanting to
concatenate all these together, but with " Or Like " between each string.
This is to enable me to prepare a long criteria expression for Access
without all the re-typing.

And for the life of me I can't think of a simple, quick way.

Any help greatly appreciated.

Jason
 
G

Gord Dibben

Jay

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

In de-limiter inputbox enter <space>or like<space>
 
J

Jay

Thanks Guys, most appreciated. I've installed the UDF into my UDF
module & will be trying your vb as well Cord. Many thanks,

Jason
 
Top