|
数组和单元格计算,一次只能用一种,多了必然出错:它们之间很难建立起来交互的桥梁
- Sub clear()
- Call vlookup '自定义过程或函数的名字,最好不要和系统内置的重复
-
- Application.ScreenUpdating = False
- Dim i&, j&, d As Object
- Dim rng As Range
- Dim cell As Range
- Sheets("成绩处理").Activate
- maxrow = Cells(Rows.Count, "B").End(3).Row
- Set rng = Sheets("成绩处理").Range("s1:s" & maxrow)
- Set d = CreateObject("scripting.dictionary")
- arr = Sheets("成绩处理").Range("a1").CurrentRegion
- brr = Sheets("学生信息").Range("a1").CurrentRegion
- With Sheets("学生信息")
- For i = 2 To UBound(brr, 1)
- If Not d.exists(brr(i, 1)) Then
- d(brr(i, 1)) = brr(i, 5) '考号为字典的键值,语种为项目
- End If
- Next i
- End With
-
- With Sheets("成绩处理")
- For j = 2 To UBound(arr, 1)
- yz = d(arr(j, 2))
- Select Case yz
- Case "英"
- arr(j, 7) = ""
- arr(j, 8) = ""
- Case "日"
- arr(j, 6) = ""
- arr(j, 8) = ""
- Case "西"
- arr(j, 6) = ""
- arr(j, 7) = ""
- Case Else
- End Select
- Next j
-
- k = 1
- '修正非本组合的其它学科成绩
- Do While k < maxrow
- k = k + 1
- Select Case Sheets("成绩处理").Cells(k, 19).Value
- Case "政史地"
- arr(k, 9) = ""
- arr(k, 10) = ""
- arr(k, 11) = ""
- arr(k, 15) = WorksheetFunction.Sum(Range("d" & k & ":N" & k))
- Case "物化生"
- arr(k, 12) = ""
- arr(k, 13) = ""
- arr(k, 14) = ""
- arr(k, 15) = WorksheetFunction.Sum(Range("d" & k & ":N" & k))
- Case "物化地"
- arr(k, 11) = ""
- arr(k, 12) = ""
- arr(k, 13) = ""
- arr(k, 15) = WorksheetFunction.Sum(Range("d" & k & ":N" & k))
- Case "政史生"
- arr(k, 9) = ""
- arr(k, 10) = ""
- arr(k, 14) = ""
- arr(k, 15) = WorksheetFunction.Sum(Range("d" & k & ":N" & k))
- Case Else
- MsgBox "难道还有没有处理的类型?"
- End Select
- Loop
- End With
-
- [a1].Resize(UBound(arr), 19) = arr
- Set d = Nothing
-
- Application.ScreenUpdating = True
- MsgBox "OK"
-
- End Sub
复制代码 |
|