Sub 班级赋分()
Dim ar As Variant, br As Variant
Dim i As Long, r As Long, rs As Long
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("学科核算")
r = .Cells(Rows.Count, 1).End(xlUp).Row
ar = .Range(.Cells(1, 1), .Cells(r, 14))
End With
For j = 3 To UBound(ar, 2) - 1
For i = 2 To UBound(ar)
If ar(i, 14) = "A" Then
zd = ar(i, 1) & ar(i, 2)
Else
zd = ar(i, 1)
End If
zf = ar(i, 14) & ar(1, j)
d(zd) = i
d(zf) = j
Next i
Next j
With Sheets("班级赋分")
rs = .Cells(Rows.Count, 1).End(xlUp).Row
br = .Range(.Cells(1, 1), .Cells(rs, "aj"))
For j = 15 To UBound(br, 2)
If br(1, j) = "" Then br(1, j) = br(1, j - 1)
zf = br(1, j) & br(2, j)
If j < 26 Then
llh = 2
Else
llh = 1
End If
For i = 2 To UBound(br)
zd = br(i, llh)
xh = d(zd)
lh = d(zf)
If xh <> "" And lh <> "" Then
br(i, j) = ar(xh, lh)
End If
Next i
Next j
.Range(.Cells(1, 1), .Cells(rs, "aj")) = br
End With
MsgBox "ok!"
End Sub
|