|
直接数组赋值就行。
代码如下:
- Sub xs()
- Dim arr(), RD1(), RD2(), RD3(), RD4(), RD5(), RD6(), RD7(), Drr
- Dim E&, i&, v$, k&, j&, t
- Dim x1&, x2&, x3&, x4&, x5&, x6&, x7&
- t = Timer
- E = Cells(Rows.Count, 3).End(3).Row
- arr = Range("a2:s" & E).Value2
- Drr = Array("RD1", "RD2", "RD3", "RD4", "RD5", "RD6", "RD7")
- For i = 0 To UBound(Drr)
- k = Application.CountIf(Range("c2:c" & E), Drr(i))
- If Drr(i) = "RD1" Then ReDim RD1(1 To k, 1 To 16)
- If Drr(i) = "RD2" Then ReDim RD2(1 To k, 1 To 16)
- If Drr(i) = "RD3" Then ReDim RD3(1 To k, 1 To 16)
- If Drr(i) = "RD4" Then ReDim RD4(1 To k, 1 To 16)
- If Drr(i) = "RD5" Then ReDim RD5(1 To k, 1 To 16)
- If Drr(i) = "RD6" Then ReDim RD6(1 To k, 1 To 16)
- If Drr(i) = "RD7" Then ReDim RD7(1 To k, 1 To 16)
- Next
- For i = 1 To UBound(arr)
- v = arr(i, 3)
- If v = "RD1" Then
- x1 = x1 + 1
- For j = 1 To 16
- RD1(x1, j) = arr(i, j)
- Next
- ElseIf v = "RD2" Then
- x2 = x2 + 1
- For j = 1 To 16
- RD2(x2, j) = arr(i, j)
- Next
- ElseIf v = "RD3" Then
- x3 = x3 + 1
- For j = 1 To 16
- RD3(x3, j) = arr(i, j)
- Next
- ElseIf v = "RD4" Then
- x4 = x4 + 1
- For j = 1 To 16
- RD4(x4, j) = arr(i, j)
- Next
- ElseIf v = "RD5" Then
- x5 = x5 + 1
- For j = 1 To 16
- RD5(x5, j) = arr(i, j)
- Next
- ElseIf v = "RD6" Then
- x6 = x6 + 1
- For j = 1 To 16
- RD6(x6, j) = arr(i, j)
- Next
- ElseIf v = "RD7" Then
- x7 = x7 + 1
- For j = 1 To 16
- RD7(x7, j) = arr(i, j)
- Next
- End If
-
- Next
- MsgBox "ok:" & Timer - t
- Stop
- End Sub
复制代码
|
|