|
Sub 按钮1_Click()
On Error Resume Next
Set Rng = Application.InputBox("请选择部门区域", "部门区域", , , , , , 8)
If Err.Number <> 0 Then
MsgBox "选择区域有误"
Exit Sub
End If
If Rng.Columns.Count <> 1 Then
MsgBox "选择区域多于1列"
Exit Sub
End If
Application.ScreenUpdating = False
Application.DisplayAlerts = False
c = Rng.Cells(1).Column
Rng.Offset(0, 2).Copy Rng.Offset(0, 3)
For j = Rng.Cells(Rng.Cells.Count).Row To Rng.Cells(1).Row Step -1
If Cells(j, c) = Cells(j - 1, c) Then
Cells(j - 1, c).Resize(2).Merge
Cells(j - 1, c + 2) = Cells(j - 1, c + 2) + Cells(j, c + 2)
Cells(j - 1, c + 2).Resize(2).Merge
If Cells(j, c + 1) = Cells(j - 1, c + 1) Then
Cells(j - 1, c + 1).Resize(2).Merge
Cells(j - 1, c + 3) = Cells(j - 1, c + 3) + Cells(j, c + 3)
Cells(j - 1, c + 3).Resize(2).Merge
End If
End If
Next j
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
|
评分
-
1
查看全部评分
-
|