ahyyf 发表于 2013-12-28 22:50 - Sub Macro1()
- Dim arr, brr, crr(), d As Object, i&, r
- Set d = CreateObject("scripting.dictionary")
- arr = Sheets("地生考试成绩").Range("A1").CurrentRegion
- For i = 2 To UBound(arr)
- d(Mid(arr(i, 1), 5)) = i
- Next
- With Sheets("中考成绩")
- brr = .Range("A1").CurrentRegion
- ReDim crr(2 To UBound(brr), 1 To 3)
- For i = 2 To UBound(brr)
- r = d(Mid(brr(i, 1), 5, 2) & Right(brr(i, 1), 3))
- If r <> "" Then
- crr(i, 1) = arr(r, 5)
- crr(i, 2) = arr(r, 6)
- If brr(i, 2) <> arr(r, 2) Then crr(i, 3) = arr(r, 2)
- End If
- Next
- .[k2].Resize(i - 2, 3) = crr
- End With
- End Sub
复制代码 |