|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- Dim r%, i%
- Dim arr, brr, crr()
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("学校")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:d" & r)
- For i = 1 To UBound(arr)
- d(arr(i, 1)) = i
- Next
- End With
- With Worksheets("班级")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- brr = .Range("a2:c" & r)
- End With
- ReDim crr(1 To UBound(brr), 1 To 6)
- For i = 1 To UBound(brr)
- crr(i, 1) = brr(i, 1)
- crr(i, 5) = brr(i, 2)
- crr(i, 6) = brr(i, 3)
- If d.exists(brr(i, 1)) Then
- m = d(brr(i, 1))
- crr(i, 2) = arr(m, 2)
- crr(i, 3) = arr(m, 3)
- crr(i, 4) = arr(m, 4)
- End If
- Next
- With Worksheets("运行结果")
- .UsedRange.Offset(1, 0).Clear
- .Range("a2").Resize(UBound(crr), UBound(crr, 2)) = crr
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|