|
本帖最后由 weiyingde 于 2017-11-5 15:23 编辑
学艺不精,智能生成J、K、M列数据(即brr中的1、2、4列)能否生成L、N数据(即补全Brr数组中的3、5列数据)?
为了后续的工作,要求只用一个数组brr,并对brr进行排序(排序要在数组中进行),按得分从高到低排序。
Sub brr数组第三五列怎么生成()
Dim arr1, arr2()
Set d = CreateObject("scripting.dictionary")
Set d1 = CreateObject("scripting.dictionary")
With Worksheets("本次得分")
r = .[A65536].End(xlUp).Row
c = .[A2].End(xlToRight).Column
If r = 1 Then Exit Sub
arr1 = .Range(.Cells(2, 1), .Cells(r, c))
ReDim Preserve arr2(1 To r - 1, 1 To c)
For i = LBound(arr1) To UBound(arr1)
For j = 1 To c
arr2(i, j) = IIf(j = 1, IIf(Val(Left(arr1(i, 1), 2)) > 10, Application.Substitute(Right(arr1(i, 1), Len(arr1(i, 1)) - 2), " ", ""), _
Application.Substitute(arr1(i, 1), " ", "")), arr1(i, j))
Next
Next
For i = 1 To r - 1
d1(arr2(i, 1)) = ""
Next
ReDim brr(1 To d1.Count, 1 To 5)
For i = LBound(arr2, 2) To UBound(arr2)
If Not d.Exists(arr2(i, 1)) Then
m = m + 1
d(arr2(i, 1)) = m
brr(m, 1) = arr2(i, 1)
brr(m, 2) = 1
'brr(m,3)=?
brr(m, 4) = arr2(i, 6)
Else
brr(d(arr2(i, 1)), 2) = brr(d(arr2(i, 1)), 2) + 1
'brr(d(arr2(i, 1)), 2) =?
brr(d(arr2(i, 1)), 4) = brr(d(arr2(i, 1)), 4) + arr2(i, 6)
End If
Next
.[j2].Resize(UBound(brr, 1), UBound(brr, 2)) = brr
End With
End Sub
|
|