Unmerging and copying data in each cell

ritzkalz49

New Member
Joined
Aug 5, 2010
Messages
3
Hi, I am new to this forum and seeking help.

I am using this code to unmerge the data and copying in each cell, but it is only working in column A. I need to the same in column B & C, it doesn't work even I change the range in the code. Please help

Sub unmergeA()
Range("A1:A" & Cells(Rows.Count, "D").End(xlUp).Row).MergeCells = False
For x = 2 To Cells(Rows.Count, "D").End(xlUp).Row + 0
If Cells(x, 1) = "" Then Cells(x, 1) = Cells(x - 1, 1)
Next x
End Sub

For column B I had tried this code

Sub unmergeB()
Range("B1:B" & Cells(Rows.Count, "D").End(xlUp).Row).MergeCells = False
For x = 2 To Cells(Rows.Count, "D").End(xlUp).Row + 0
If Cells(x, 1) = "" Then Cells(x, 1) = Cells(x - 1, 1)
Next x
End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Try

Rich (BB code):
Sub unmergeB()
Range("B1:B" & Cells(Rows.Count, "D").End(xlUp).Row).MergeCells = False
For X = 2 To Cells(Rows.Count, "D").End(xlUp).Row + 0
    If Cells(X, 2) = "" Then Cells(X, 2) = Cells(X - 1, 2)
Next X
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,482
Messages
6,125,058
Members
449,206
Latest member
Healthydogs

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