Unmerging Cells and fill with value

gldurand

Board Regular
Joined
Jun 8, 2006
Messages
178
Office Version
  1. 2016
Platform
  1. Windows
Hi Team

I have a spreadsheet that is has merged cells in columns.

I want to be able to unmerge the columns and fill the cells with the value of the merged cells.

ex:
I have a VALUE1 in merged cells A1:A15, i want to have that value in each cell A1 - A2 - A3 etc to A15,
I have a VALUE2 in merged cells A16:A20, i want to have that VALUE2 in each cell A16 - A17 etc to A20

It is never consistent, so probably VBA code to unmerge all cell in that column, and copy until a new value is found, then REPEAT.

Can anyone assist? I have several files in this situation and over 10000 rows of data

Thanks
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
please upload a sample file, with current column and desired result, on a sharing site, then paste the link here
 
Upvote 0
This will unmerge merged cells which consist of a single column only, acting on all columns of the active sheet. So if a merged area consists of cells from more than one column,it'll leave it alone.
Code:
Sub unmerge()
For Each cll In ActiveSheet.UsedRange.Cells
  If cll.MergeCells Then
    If cll.MergeArea.Columns.Count = 1 Then
      With cll.MergeArea
        .MergeCells = False
        .Value = cll.Value
      End With
    End If
  End If
Next cll
End Sub
It could be speeded up, so if time of execution is a problem, post again.
 
Upvote 0
Thanks so much P45CAL, it works like a charm, this savedme a huge amount of manual work.

All the best
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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