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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
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
 

Watch MrExcel Video

Forum statistics

Threads
1,132,873
Messages
5,655,737
Members
418,234
Latest member
jdorfma

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
Top