Concatenate Multiple Rows until Non-Blank in Adjacent Column

bencookman

New Member
Joined
Mar 15, 2006
Messages
21
Hello

I would like a macro that works through a long worksheet, set up as follows:

Column A: product code (3-digit code)
Column B: notes about product (free text - can span multiple rows due to character limits)

Column A is blank in the rows where the data in column B has spilled onto multiple rows.

I would like a macro that will loop the worksheet and and concatenate the contents of column B into a new column C, so that all the notes for a given product are shown in a single row. The icing on the cake would be to delete the now redundant blank rows between product codes.

I'm struggling with the "keep concatenating the rows in column B until you find a non-blank entry in column A" piece of it. All help appreciated.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
If this is a one off then you really don't need a macro for the task.

Assuming headers in row 1, data starting in row 2, enter this formula into C2 and fill down to the end of your data.

=IF(A3<>"",B2,B2&C3)

Next copy column C and pastespecial - values.

Finally, filter column A to show only blanks and delete the visible rows.
 
Upvote 0
If this is a one off then you really don't need a macro for the task.

Assuming headers in row 1, data starting in row 2, enter this formula into C2 and fill down to the end of your data.

=IF(A3<>"",B2,B2&C3)

Next copy column C and pastespecial - values.

Finally, filter column A to show only blanks and delete the visible rows.


Jason - many thanks - works a treat, and would never have thought that this could be so simple!
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,190
Members
452,616
Latest member
intern444

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