I can't use ctrl z(Undo) after using the following code in excel 2019.
I want to merge 8 rows into a cell by using macros but I hope it can undo.
here is the code:
Sub main()
Dim i As Long
With ActiveSheet
For i = 1 To .Cells(Rows.Count, 1).End(xlUp).Row Step 8
With .Cells(i, 1).Resize(8)
.Merge
.HorizontalAlignment = xlCenterAcrossSelection
.VerticalAlignment = xlCenter
End With
With .Cells(i, 2).Resize(8)
.Merge
.HorizontalAlignment = xlCenterAcrossSelection
.VerticalAlignment = xlCenter
End With
With .Cells(i, 3).Resize(8)
.Merge
.HorizontalAlignment = xlCenterAcrossSelection
.VerticalAlignment = xlCenter
End With
With .Cells(i, 4).Resize(8)
.Merge
.HorizontalAlignment = xlCenterAcrossSelection
.VerticalAlignment = xlCenter
End With
Next i
End With
End Sub