Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88126

How to unmerge rows and not column

$
0
0

I have a table which contains merged cells both column and rows as shown in attached picture. I want to unmerge "Only" rows while leaving columns merged. Consider the following snippet of table. In the image attached "Contract

enter image description here

For y = 1 To lRow
        p = 1
        c = y
        d = 1
        z = lRow + y
        t = Cells(y, 1).Value
        For x = 1 To t
        Cells(z, p).Value = Cells(c, d).Value
        Cells(c, d).Select
    '      Debug.Print
        Selection.End(xlToRight).Select
        c = ActiveCell.Row
        d = ActiveCell.Column
              p = p + 1
        Next

        Next

Sub ColorMergedCells()
Dim c As Range
Dim startcolumn, endcolumn, startrow, endrow As Long
For Each c In ActiveSheet.UsedRange
If c.MergeCells And c.MergeArea.Rows.Count >= 2 Then
c.Interior.ColorIndex = 28
With c.MergeArea.Rows
                .UnMerge
'                .Formula = c.Formula
End With
''startcolumn = ActiveCell.Column
'endcolumn = Selection.Columns.Count + startcolumn - 1
'startrow = ActiveCell.Row
'endrow = Selection.Rows.Count + startrow - 1 

End If
Next
End Sub

Viewing all articles
Browse latest Browse all 88126

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>