concatenate or merge cells for every change in a non-blank cell

natforde

New Member
Joined
Aug 26, 2021
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hi - first time poster here! any help greatly appreciated!
I am trying to use excel as a quick way to format a transcript and either concatenate or merge cells to aggregate comments by a speaker, please see below example of data and my first ideas at the logic of trying to resolve:
Column AColumn BColumn c = the output
nataliecomment 1
comment 2comment 1comment 2
othercomment 3
comment 4comment 3comment 4
nataliecomment 5comment 5
othercomment 6comment 6

herei thought i could try and make a colum (colum C) so that if cell a2 is not blank then concatenate from C2 to another cell reference (but here I need a reference for the cell up to the next non blank cell.)

Ideally i would like the final data to look like this:
Column AColumn c (merged for each cell where speaker is natalie)
nataliecomment 1comment 2
othercomment 3comment 4
nataliecomment 5
othercomment 6

does anyone have any suggestions please? happy with formulas or i could try and run VBA but its been a few years - maybe i need a loop in VBA?
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
i have found a similar problem but it doesnt seem to work so not sure why?
Column AColumn BColumn c = the outputtrialoutput
nataliecomment 1=IF(A2="","",TEXTJOIN(", ",1,B2:INDEX(B:B,IFERROR(MATCH(A2+1,A:A,0)-1,MATCH("zzz",B:B)))))comment 1, comment 2, comment 3, comment 4, comment 5, comment 6
comment 2comment 1comment 2
othercomment 3=IF(A4="","",TEXTJOIN(", ",1,B4:INDEX(B:B,IFERROR(MATCH(A4+1,A:A,0)-1,MATCH("zzz",B:B)))))comment 3, comment 4, comment 5, comment 6
comment 4comment 3comment 4
nataliecomment 5comment 5=IF(A6="","",TEXTJOIN(", ",1,B6:INDEX(B:B,IFERROR(MATCH(A6+1,A:A,0)-1,MATCH("zzz",B:B)))))comment 5, comment 6
othercomment 6comment 6=IF(A7="","",TEXTJOIN(", ",1,B7:INDEX(B:B,IFERROR(MATCH(A7+1,A:A,0)-1,MATCH("zzz",B:B)))))comment 6
 
Upvote 0
Welcome to the MrExcel board!

Would this be any use? (So long as the list/comments are not too big)

21 08 26.xlsm
ABC
1NameCommentComments
2nataliecomment 1comment 1comment 2
3comment 2 
4othercomment 3comment 3comment 4
5comment 4 
6nataliecomment 5comment 5
7othercomment 6comment 6
8
Concat Comments
Cell Formulas
RangeFormula
C2:C7C2=IF(A2="","",LET(t,CONCAT(B2:B$8),LEFT(t,LEN(t)-LEN(CONCAT(C3:C$8)))))
 
Last edited:
Upvote 0
Upvote 0
Try this perhaps?

=IF(A2<>"",IFERROR(TEXTJOIN(",",TRUE,INDEX(B2:INDEX(B2:$B$100,MATCH(FALSE,ISBLANK(A3:$A$1000),0)),0)),B2),"")
 
Upvote 0
perfect thank you so much!! :) this forum is brilliant!

Try this perhaps?

=IF(A2<>"",IFERROR(TEXTJOIN(",",TRUE,INDEX(B2:INDEX(B2:$B$100,MATCH(FALSE,ISBLANK(A3:$A$1000),0)),0)),B2),"")
thank you - i am just trying it on real data and i have spill error so not sure what is happening - maybe too many characters for one cell?
 
Upvote 0
perfect thank you so much!!
You're welcome. Thanks for the follow-up.


Try this perhaps?

=IF(A2<>"",IFERROR(TEXTJOIN(",",TRUE,INDEX(B2:INDEX(B2:$B$100,MATCH(FALSE,ISBLANK(A3:$A$1000),0)),0)),B2),"")
@steve the fish
Note that this formula fails if the last name has more than one comment - see column D below.
Also not sure if you meant to use 100 rows in one spot and 1000 rows in another?
Anyway, correction suggested in column E.

21 08 26.xlsm
ABDE
1NameComment
2nataliecomment 1comment 1,comment 2comment 1,comment 2
3comment 2  
4othercomment 3comment 3,comment 4comment 3,comment 4
5comment 4  
6nataliecomment 5comment 5comment 5
7othercomment 6comment 6comment 6,comment 7,comment 8
8comment 7  
9comment 8  
10
Concat Comments
Cell Formulas
RangeFormula
D2:D9D2=IF(A2<>"",IFERROR(TEXTJOIN(",",TRUE,INDEX(B2:INDEX(B2:$B$100,MATCH(FALSE,ISBLANK(A3:$A$1000),0)),0)),B2),"")
E2:E9E2=IF(A2<>"",TEXTJOIN(",",TRUE,INDEX(B2:INDEX(B2:$B$100,IFNA(MATCH(FALSE,ISBLANK(A3:$A$100),0),ROWS(B2:B$100))),0)),"")
 
Upvote 0
Solution

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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