|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
数组+字典法速度快些,请参考:- Sub Macro2() '数组法
- Dim d As Object, i&, j%, arr, c As Range
- With Sheets("分布")
- Set c = .[b2:f2].Find([i3], , , 1)
- If c Is Nothing Then
- MsgBox "该课程不存在,请重新输入!", vbInformation
- Exit Sub
- End If
- arr = .[a1].CurrentRegion
- End With
- Set d = CreateObject("scripting.dictionary")
- j = c.Column
- For i = 3 To UBound(arr)
- d(arr(i, 1)) = arr(i, j)
- Next
- arr = Range("a11:a" & [a65536].End(xlUp).Row)
- For i = 1 To UBound(arr)
- arr(i, 1) = d(arr(i, 1))
- Next
- [v11:v65536].ClearContents
- [v11].Resize(i - 1) = arr
- End Sub
复制代码 |
|