|
楼主试一下这个,测试没啥问题
Sub 计算()
Dim ArrAll, Arr1, Arr2
Dim Str1$
Dim i As Long, j%, m%, n%
Dim dic1 As Object
Dim dic2 As Object
Excel.Application.ScreenUpdating = False
Arr1 = Array("Q2", "X2", "AE2", "AL2", "AS2") '五个数据范围的位置
Set dic1 = CreateObject("scripting.dictionary")
ArrAll = Cells(10, 3).CurrentRegion
For i = LBound(ArrAll, 1) To UBound(ArrAll, 1)
For j = LBound(ArrAll, 2) To UBound(ArrAll, 2)
If ArrAll(i, j) <> "" Then
ArrAll(i, j) = CInt(Right(ArrAll(i, j), 1))
dic1(ArrAll(i, j)) = ""
End If
Next j
Cells(i + 9, 17).Value = dic1.Count
Set dic2 = dic1
For j = 0 To 4
Arr2 = Range(Arr1(j)).CurrentRegion
For m = 2 To UBound(Arr2, 1)
For n = 1 To UBound(Arr2, 2)
If Arr2(m, n) <> "" Then dic1(Arr2(m, n)) = ""
Next n
Next m
Cells(i + 9, 18 + j).Value = dic1.Count
Set dic1 = dic2
Next j
dic1.RemoveAll
Next i
Range("J10").Resize(UBound(ArrAll, 1), UBound(ArrAll, 2)) = ArrAll
Set dic1 = Nothing
Set dic2 = Nothing
Excel.Application.ScreenUpdating = True
End Sub |
评分
-
1
查看全部评分
-
|