VBA - Concatenate - Dynamic Range - Row by Row

MKader

New Member
Joined
May 15, 2015
Messages
19
Hi All -

Need your help -

Was able to concatenate selected cells and value is placed in a designated cell -

How can I repeat the same process for all rows till the end of data in column -

Code:
Private Sub Trial_1_Click()
Dim CC As Range
Dim i As Integer
Dim TT As String
i = 0
TT = ""
For Each CC In Selection
If i = 0 Then
i = 1
End If
TT = TT & CC.Value & ""
Next
TT = Left(TT, Len(TT))
Range("P2").Value = TT
End Sub


Thanks,
MK
 
The last one you provided - Thanks :) ..

Am trying to find a way to replicate the original selection and applying to the next row and so on till empty cell -

Do you think loop would work ?

Thanks,
MK
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
My code has a loop.
With data shown in columns J:M below, with K2:L2 selected, the code produced the results in P2:P5. Is that not what you described you wanted in post #7?

Excel Workbook
JKLMNOP
1Data 1Data 2Data 3Data 4Result
2123423
3567867
491011121011
5131415161415
6
Concat
 
Upvote 0
Hi -

Yea - that's what I was looking for - yet it only works if you highlight every row and then click the button -

It doesn't go through the list by itself -

Thanks,
MK
 
Upvote 0
Hi Peter -

I tried it several times - it doesn't loop and basically it does the same function in my initial code -

Any advice ?

Thanks,
MK
 
Upvote 0
Do you have any other code in the workbook?

What version of Excel & what operating system are you using?

Start a fresh, blank workbook with a single worksheet,
- put the sample data exactly as shown in post #12 (columns J:M only),
- put the last code I gave you into that new workbook,
- close any other open workbooks,
- select K2:L2,
- run the code & report the results.
 
Last edited:
Upvote 0
Hi Peter -

Your help is much appreciated -

I followed the exact steps - the result is that the highlighted cells are only concatenated and I have to highlight row by row to have the results -

Am using a WIN 7 Prof and Office 2013 -

Also - No other codes on the workbook -

Thanks,
MK
 
Upvote 0
I cannot think why your experience is so different to mine. In this case I would like to see a copy of an actual workbook of yours that is behaving in the way you describe. There is two ways to do that...
1. Upload a copy of such a workbook to a public file-share site and provide the link in a post in this thread, or
2. I will send you a PM with an email address you can provide the file to. If this course is chosen, I will publish any finding results back here in the public thread.

In either case, please describe what your cell selection in the sample workbook was was before running the code so that I can exactly replicate you actions.
 
Upvote 0

Forum statistics

Threads
1,225,611
Messages
6,185,996
Members
453,334
Latest member
Prakash Jha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top