How do I concatenate in a loop based on a condition

naa

New Member
Joined
Jul 2, 2021
Messages
1
Office Version
  1. 2013
Platform
  1. Windows
I want to concatenate several cells into 1 according to condition that there is a break whenever it encounters text "object-group" and then it should start a new concatenate.

Image explains better about what im looking for. I have a LONG list of data in 1 column format, please see image for better explanation of what im after.

I know the concatenate function along with CHAR(10) for line break, but cant figure out how to automate this.


concatenate assistance needed.JPG


Im looking to fill down formula for column E.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Firstly, your request is doable, but I'd suggest using the XL2BB link to paste real data to the forum rather than and image. Most posters won't bother retyping all of your dat to test it.
See my link for the XL2BB download, then paste the copied data back here.
 
Upvote 0
Try this for starters
VBA Code:
Sub MM1()
 Dim r As Long, t As String
 t = ""
For r = Cells(Rows.Count, "B").End(xlUp).Row To 3 Step -1
     If InStr(Cells(r, 2), "object-group") = 0 Then
        t = Cells(r, 2) & Chr(10) & t
        Cells(r, 2).Clear
     Else
         Cells(r, 5) = t
         t = ""
     End If
 Next r
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,014
Messages
6,122,697
Members
449,092
Latest member
snoom82

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