|
代码如下:
- Private Sub Worksheet_Change(ByVal T As Range)
- If T.Column < 2 Or T.Column >= 100 And T.Row < 5 Then Exit Sub
- Dim arr, d
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("班级课时")
- r = .Cells(.Rows.Count, "a").End(xlUp).Row
- c = .UsedRange.Columns.Count
- arr = .[a1].Resize(r, c)
- End With
- For i = 2 To UBound(arr)
- For j = 2 To UBound(arr, 2)
- S = arr(i, 1) & "|" & arr(1, j)
- d(S) = Val(arr(i, j))
- Next
- Next
- On Error Resume Next
- With Sheets("汇总")
- r = .Cells(.Rows.Count, "a").End(xlUp).Row
- c = .UsedRange.Columns.Count
- arr = .[a1].Resize(r, c)
- .Cells.Interior.ColorIndex = 0
- For i = 5 To UBound(arr)
- For j = 2 To UBound(arr, 2)
- If arr(i, j) <> Empty Then
- b = Split(arr(i, j), Chr(10))
- S = arr(i, 1) & "|" & b(0)
- If d.Exists(S) Then
- m = Val(Mid(b(1), 3))
- If m > d(S) Then .Cells(i, j).Interior.ColorIndex = 3
- If m < d(S) Then .Cells(i, j).Interior.ColorIndex = 8
- End If
- End If
- Next
- Next
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|