ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Concatenate Question (https://www.excelbanter.com/excel-programming/385301-concatenate-question.html)

Dan R.

Concatenate Question
 
I'm using this to concat. all of Col A into cell B1. But rather than
concat. the entire column I'd like to split it up into parts. For
example, concat. Range("A1:A50") into cell B1, Range("A51:A100") into
cell B2, etc. Thanks guys, here's my code:

Sub ConCat()
Dim Val As String
Dim iEnd As Long
Dim i As Long

iEnd = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row

For i = 1 To iEnd
Val = Val & Cells(i, 1) & ","

Cells(1, "B").Value = Val

Next i
End Sub

Thank You,
-- Dan


Ron de Bruin

Concatenate Question
 
Hi Dan

Try J.E's code
http://www.mcgimpsey.com/excel/udfs/multicat.html


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Dan R." wrote in message ups.com...
I'm using this to concat. all of Col A into cell B1. But rather than
concat. the entire column I'd like to split it up into parts. For
example, concat. Range("A1:A50") into cell B1, Range("A51:A100") into
cell B2, etc. Thanks guys, here's my code:

Sub ConCat()
Dim Val As String
Dim iEnd As Long
Dim i As Long

iEnd = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row

For i = 1 To iEnd
Val = Val & Cells(i, 1) & ","

Cells(1, "B").Value = Val

Next i
End Sub

Thank You,
-- Dan


Dan R.

Concatenate Question
 
That's perfect Ron, thanks.

-- Dan



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

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