Merge Cells into One Cell based on Contents of Another Column

dcbuzzell

New Member
Joined
Jan 22, 2013
Messages
36
Hello All - Excel 2010 issues. I need to combine multiple cells in Column B that represent one to three descriptive lines for the data in Column A. I would like the contents of the descriptive lines separated by a space, merged into the first cell and the duplicative rows deleted.


Excel 2010
AB
1MODELDESCRIPTION
2abc1234Part 1 Line 1
3Part 1 Line 2
4Part 1 Line 3
5abc5678Part 2 Line 1
6Part 2 Line 2
7Part 2 Line 3
8abc9012Part 3 Line 1
9Part 3 Line2
10Part 3 Line 3
11bcd1234Part 4 Line 1
12Part 4 Line2
13bcd4567Part 5 Line 1
14bcd8901Part 6 Line 1
15Part 6 Line 2
16Part 6 Line 3
17cde1234Part 7 Line 1
18Part 7 Line 2
19cde5678Part 8 Line 1
Sheet2


In this example, Cells B2:B4 would be combined into B2, separated by a space; Rows 3 and 4 would be deleted. Then cells B5:B7 would be combined in B5, and Rows 6 and 7 deleted. Continuing down in similar fashion, Row 13 would be unchanged.

Thanks in advance for any help.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
While the request is doable, why would you want to combine data into one cell ?
It will make it very difficult to do anything else with it once the "merge" has been done !
 
Upvote 0
Thank you for your reply.

The data should be combined, but is separated into (up to) three cells by the arcane system it's coming from - combined, they are the long description for the data in Column A. In order to sort and analyze the data, I need the data in column B merged as I mentioned.
 
Upvote 0
OK, try this
Code:
Sub MM2()
Dim r As Long
For r = Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
    If Range("A" & r).Value = "" Then
        Range("B" & r - 1).Value = Range("B" & r - 1).Value & " " & Range("B" & r).Value
        Rows(r).Delete
    End If
Next r
End Sub
 
Upvote 0
Hi Michael,

What I need is exactly inverse to him.
The content in my column B is all in one cell, and devided by space.
I can let the column B split into separate cells, but the content in column A will not match with the column B anymore.
Do you have some suggestions?

Thanks in advance!
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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