vba to help with merged cells

dshafique

Board Regular
Joined
Jun 19, 2017
Messages
171
Hey guys, I am trying to create a macro which deals with merged cells. The data I deal with comes from a table in powerpoint. when i copy the data over a lot of the cells end up being merged (I'm not sure why, but it's not merged in the ppt). what I want to do is to unmerge all the cells, then append any data that's in the blank lines in between. there are only 2 columns which have data that isnt merged.

John SmithDataDataDataDataDataDataemail Dataapp datadata
email dataapp data
email dataapp data
john smithdata datadatadatadatadataemail dataapp datadata
app data

<tbody>
</tbody>

roughly how the table looks after unmerging


basically pseudo code:

1.) select everything
2.) unmerge cells
3.) check name cell to see if it's empty
if empty check if email data column is empty
if email data column is NOT empty, append data to email data cell above
else check app data cell and if NOT empty, append to the cell above.
4.) delete the whole row after

if anyone could give any guidelines that would be greatly appreciated. thanks
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
How about
Code:
Sub UnMergeCombine()
   Dim Rng As Range
   
   ActiveSheet.UsedRange.MergeCells = False
   For Each Rng In Range("G:G").SpecialCells(xlBlanks).Areas
      Rng.Offset(-1, 1).Resize(1, 1).Value = Join(Application.Transpose(Rng.Offset(-1, 1).Resize(Rng.Count + 1).Value), ", ")
      Rng.Offset(-1, 2).Resize(1, 1).Value = Join(Application.Transpose(Rng.Offset(-1, 2).Resize(Rng.Count + 1).Value), ", ")
   Next Rng
   Range("G:G").SpecialCells(xlBlanks).EntireRow.Delete
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,391
Messages
6,119,249
Members
448,879
Latest member
oksanana

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