|
Sub test()
Set d = CreateObject("scripting.dictionary")
arr = [a1].CurrentRegion
r = 3
For j = 4 To UBound(arr)
str1 = ""
For i = 2 To 11
str1 = str1 & arr(j, i)
Next i
If d.exists(str1) Then
arr(d(str1), 6) = Val(arr(d(str1), 6)) + Val(arr(j, 6))
Else
r = r + 1
For i = 2 To UBound(arr, 2)
arr(r, i) = arr(j, i)
Next i
arr(r, 1) = r - 3
d(str1) = r
End If
Next j
[a1].CurrentRegion.ClearContents
[a1].Resize(r, UBound(arr, 2)) = arr
arr = [a1].CurrentRegion
Application.ScreenUpdating = False
Application.DisplayAlerts = False
With CreateObject("vbscript.regexp")
.Pattern = "×\d+"
.Global = True
For j = Cells(Rows.Count, 3).End(3).Row To 2 Step -1
If Cells(j, 3) = Cells(j - 1, 3) Then
Cells(j - 1, 3).Resize(2).Merge
Cells(j - 1, 2).Resize(2).Merge
Cells(j, "k") = .Replace(Cells(j, "k"), "")
Cells(j - 1, "k") = .Replace(Cells(j - 1, "k"), "")
End If
Next j
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
|
评分
-
1
查看全部评分
-
|