|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- ' Set reg = CreateObject("vbscript.regexp")
- With Worksheets("评分标准")
- r = .UsedRange.Find(what:="*", LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows, searchdirection:=xlPrevious).Row
- brr = .Range("a1:i" & r)
- For j = 2 To UBound(brr, 2) Step 3
- d(brr(1, j)) = j
- Next
- End With
- With Worksheets("学生名册")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a1:k" & r)
- For j = 6 To UBound(arr, 2) Step 2
- If d.exists(arr(1, j)) Then
- n1 = d(arr(1, j))
- For i = 2 To UBound(arr)
- n2 = IIf(arr(i, 5) = "男", 0, 1)
- If Len(arr(i, j)) <> 0 Then
- For k = 3 To UBound(brr)
- If arr(i, j) >= brr(k, n1 + n2) Then
- arr(i, j + 1) = brr(k, n1 - 1)
- Exit For
- End If
- Next
- If k > UBound(brr) Then
- arr(i, j + 1) = 0
- End If
- End If
- Next
- End If
- Next
- .Range("a1").Resize(UBound(arr), UBound(arr, 2)) = arr
- End With
- End Sub
复制代码 |
|