|
Private Sub CommandButton1_Click()
Dim irow As Integer
Dim i As Integer
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set d = CreateObject("scripting.dictionary")
With ActiveSheet
arr = .Range("a1:b" & .Cells(.Rows.Count, 1).End(3).Row)
End With
ReDim brr(1 To UBound(arr), 1 To 4)
For i = 1 To UBound(arr)
d(arr(i, 1)) = d(arr(i, 1)) + 1
Next
For i = 2 To UBound(arr)
If d.exists(Range("A" & i).Value) Then
x = d(Range("A" & i).Value)
Range(Range("a" & i), Range("a" & i + x - 1)).Merge '单元格合并
i = i + x - 1
End If
Next
Application.ScreenUpdating = False
Application.DisplayAlerts = True
End Sub |
|