|
代码如下。。。
Sub test()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
arr = [a1].CurrentRegion
s = Split("GRN GRS GICR GIGD")
n = 1
For i = UBound(arr) To 2 Step -1
For j = 0 To UBound(s)
If InStr(arr(i, 4), s(j)) Then
If InStr(arr(i - 1, 4), s(j)) Then
n = n + 1
Range(Cells(i, 1), Cells(i - 1, 1)).Merge
Range(Cells(i, 3), Cells(i - 1, 3)).Merge
Range(Cells(i, 2), Cells(i - 1, 2)).Merge
Else
Cells(i, 2) = n
n = 1
End If
Exit For
End If
Next
Next
Application.DisplayAlerts = True
Application.DisplayAlerts = True
Beep
End Sub
|
|