Unmerging cells and replacing data within unmerged cells

gvillepa

New Member
Joined
Oct 18, 2017
Messages
36
I have hundreds of merged cells in column a. The merged cell is a header for the row data, but I need to unmerge the cells but have the header apply to the cells that are unmerged. When I unmerge the cell, the header defaults to the top row only of that section. I also have hundreds of merged cells in column a, of different titles, so I am trying to find a quick way to unmerge and place the header in all cells, find the next unmerged header and place that header in the blanks of the section, and repeat. Thoughts/formulas?
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
The unmerge is simply selecting the column the Format Cells > Alignment > Uncheck the merged cells box. I suspect you probably know this already.
There are several ways of filling the group heading cells down. See the link here:-
3 Ways to Fill Down Blank Cells in Excel - Excel Campus
In addition to that you could also use a spare column at the end do something like the below then copy the values to get rid of the formulas

Book1
AB
1Column HdgRepeat Hdg
2Test1Test1
3Test1
4Test2Test2
5Test2
6Test2
7Test3Test3
8Test3Test3
9Test3
10Test3
Sheet1
Cell Formulas
RangeFormula
A8A8=A7
B2:B10B2=IF($A2="",B1,$A2)
 
Upvote 0
Solution
Code:
Sub AAAAA()
Dim c As Range, ma As String, mav As String
    For Each c In Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row)
        If c.MergeCells = True Then
            ma = c.MergeArea.Address(0, 0)
            mav = c.MergeArea.Cells(1, 1).Value
        End If
        c.MergeCells = False
        Range(ma).Value = mav
    Next c
End Sub
And what Alex suggested in code mode.
Code:
Sub Maybe()
With Range("A1:A" & Cells(Rows.Count, 2).End(xlUp).Row)
    .MergeCells = False
    .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
    .Value = .Value
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,251
Members
448,556
Latest member
peterhess2002

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