Private Sub CommandButton1_Click() Application.ScreenUpdating = False Dim i As Integer, j As Integer Application.DisplayAlerts = False i = 3 Do Until Cells(i, “A”).Value = “” j = 1 Do While Cells(i, “A”).Value = Cells(i + j, “A”).Value j = j + 1 Loop Range(Cells(i, “A”), Cells(i + j – 1, “A”)).Merge i = i + j Loop Application.DisplayAlerts = True Application.ScreenUpdating = Ture End Sub
Private Sub CommandButton1_Click() Application.ScreenUpdating = False Dim i As Range, j As Long Set i = Range(“A1”) For j = 1 To Cells(Rows.Count, 1).End(xlUp).row With Cells(j, 1) If .Value = .Offset(1, 0).Value Then Set i = Union(i, .Offset(1, 0)) Else Application.DisplayAlerts = False i.Merge Application.DisplayAlerts = True Set myRange = .Offset(1, 0) End If End With Next Application.ScreenUpdating = Ture End Sub
Private Sub CommandButton1_Click() Application.ScreenUpdating = False Dim i As Integer, myRange As Range Set myRange = Range(“A2”) For i = 1 To 5 Set myRange = myRange.Offset(1).MergeArea myRange.Value = i Next i Set myRange = Nothing Application.ScreenUpdating = Ture End Sub
Private Sub CommandButton2_Click() Application.ScreenUpdating = False Range(“A:A,D:D”).UnMerge Dim i As Integer For i = 3 To 145 Cells(i, 1).Value = Cells(i, 27).Value Cells(i, 4).Value = Cells(i, 30).Value Next Range(“A2:F72,A75:F145”).Borders.LineStyle = xlContinuous Range(“A2:D72,A75:D145,D2:F72,D75:F145”).BorderAround Weight:=xlMedium Application.ScreenUpdating = Ture End Sub