Unmerging cells

mplees

Active Member
Joined
Feb 6, 2006
Messages
351
Hi came across this code on the internet (I think originally created by Mike Rickson):

Code:
Dim oneCell As Range, onesFriends As Range
With ThisWorkbook.Activesheet
    For Each oneCell In .UsedRange
        If oneCell.MergeCells Then
            Set onesFriends = oneCell.MergeArea
            oneCell.UnMerge
            onesFriends.Value = oneCell.Value
        End If
    Next oneCell
End With

This almost does what I need - it unmerges all the merged cells, but each of the unmerged cells repeats the data that was originally in the merged cells. Is it possible to modify the code so that the cells are unmerged, but only the first of each unmerged cells contains the data?

Hope someone can help me out

Regards

Mark
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
I would think removing this line would do that..

onesFriends.Value = oneCell.Value
 
Upvote 0
This single line of code will unmerge all merged cells on the ActiveSheet and leave the value that was in the merged cells in the upper left cell of each merged area....

Cells.Unmerge
 
Upvote 0
Gentlemen,
Thank you both for your help - much appreciated.
Since you said "thank you both", that probably means you didn't see my original message yet (as I am the third responder;)), so I am responding again hoping you will notice the new message in your thread and come back to the forum to read it.
 
Upvote 0
Rick,

My apologies - sorry I missed your post, and thank you for your assistance.

regards

Mark
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

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