I am working on a macro to unmerge merged cells in a given range and then re merge the original merged cells which were unmerged. I have been struggling to identify how to store a list of the cells which are initially unmerged so that the macro can re merge those exact cells.The rows that are merged in the spreadsheet change from week to week.
Sub MergeUnmerge()
'
Mergeunmerge Macro
'
Dim mergelist As Range
Dim celllist As Range
For Each cell In Range("A1:S49")
If cell.MergeCells = True Then
Set mergelist = celllist
cell.UnMerge
End If
Next
For Each cell In mergelist
Range("celllist").Merge
Next
End Sub