Merge Multiple Lines into One Cell Reference Noncontiguous Range

Luke7731

New Member
Joined
Feb 13, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I have two columns, one with the case number, and the other with varying amount of rows of related case notes (so varying amount of blank rows under each case number). Hundreds of cases, thousands of rows of case notes.
I’ve attached an image of what I have vs what I need. I need the case notes to remain one line on top of the next but I need all of the case notes associated with a case number to be in a single cell next to that case number cell.
So an automated way to merge multiple individual lines of text of various size into a single cell, grouped based on the case numbers to the side.

Thanks!
 

Attachments

  • IMG_2451 Medium.jpeg
    IMG_2451 Medium.jpeg
    117.6 KB · Views: 17

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
The below version is about 17 seconds for 11K+ rows:
Excel Formula:
=LET(a,$A$5:$A$11194,b,$B$5:$B$11194,c,ROW(a),u,SORT(FILTER(a,LEN(a)),1,1),HSTACK(u,BYROW(u,LAMBDA(br,TEXTJOIN(CHAR(10),,FILTER(b,LOOKUP(c,IF(LEN(a),c), a)=br))))))
 
Upvote 0
I tested it wih 11000 rows of data, it works - takes around 30 seconds to calculate.
Fair enough. I hadn't tested your formula, but I guessed that it would be pretty slow on data that big.
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,289
Members
449,077
Latest member
Rkmenon

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