concatenate row to last column with data

dtopinka

New Member
Joined
Nov 2, 2020
Messages
18
Office Version
  1. 2013
Platform
  1. Windows
can someone proved me with vba code to concatenate all cells in a row to the last blank cell. Between each concatenation i would like a semicolon and blank space (; )


see the sheet provided in the link for my data example
Row 1 has one column with data.. Row 2 has 3 columns with data.. and so on..

I would like to concatenate all row columns with data into column A. Then repeat process to the final row.

 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Cross-posted here: concatenate row to last blank cell - OzGrid Free Excel/VBA Help Forum

While we do allow Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered elsewhere.
 
Upvote 0
Do you want to place the concatenated data for each row at the bottom of column A with the data for each row in one cell?
 
Upvote 0
Do you want to place the concatenated data for each row at the bottom of column A with the data for each row in one cell?
No.. I would like the concatenated values to be in their corresponding row.. so row 1 will be row 1 column a, row 2 column a and so on..

or i can make a new column (column a) and all the concatenations can be in that column to corresponding row.
 
Upvote 0
How about
VBA Code:
Sub dtopinka()
   Dim Ary As Variant
   Dim r As Long, c As Long
   
   Ary = Range("A1").CurrentRegion.Value2
   For r = 2 To UBound(Ary)
      For c = 2 To UBound(Ary, 2)
         If Ary(r, c) = "" Then Exit For
         Ary(r, 1) = Ary(r, 1) & "; " & Ary(r, c)
      Next c
   Next r
   Range("A1").Resize(UBound(Ary), 1).Value = Ary
End Sub
 
Upvote 0
Solution
Cross-posted here: concatenate row to last blank cell - OzGrid Free Excel/VBA Help Forum

While we do allow Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered elsewhere.
Hello Joe4. sorry about that.
 
Upvote 0
How about
VBA Code:
Sub dtopinka()
   Dim Ary As Variant
   Dim r As Long, c As Long
  
   Ary = Range("A1").CurrentRegion.Value2
   For r = 2 To UBound(Ary)
      For c = 2 To UBound(Ary, 2)
         If Ary(r, c) = "" Then Exit For
         Ary(r, 1) = Ary(r, 1) & "; " & Ary(r, c)
      Next c
   Next r
   Range("A1").Resize(UBound(Ary), 1).Value = Ary
End Sub
YES! Thank you!!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Hello Joe4. sorry about that.
We typically do not ban members for first-time offenses (unless they are really egregious).
However, I do recommend reading through those rules, just so you know what they are and can avoid any other issues.

Thanks!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,517
Members
449,088
Latest member
RandomExceller01

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