|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
感觉比较麻烦,每个表要单独处理。- Sub ykcbf() '//2024.7.25
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("目标表")
- On Error Resume Next
- With Sheets("元数据1-办学层次")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 2)
- End With
- For i = 2 To UBound(arr)
- s = arr(i, 1) & "|" & arr(1, 2)
- d(s) = arr(i, 2)
- Next
- With Sheets("元数据2-选科要求")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 4)
- End With
- For i = 2 To UBound(arr)
- s = arr(i, 1) & "|" & arr(i, 3) & "|" & arr(1, 4)
- d(s) = arr(i, 4)
- Next
- With Sheets("元数据3-招生计划")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 55)
- End With
- For i = 2 To UBound(arr)
- s = arr(i, 3) & "|" & arr(i, 4) & "|" & arr(1, 5)
- d(s) = arr(i, 5)
- Next
- With sh
- r = .Cells(Rows.Count, 1).End(3).Row
- c = .UsedRange.Columns.Count
- arr = .[a1].Resize(r, c)
- .[d2:g1000] = ""
- For i = 2 To r
- s = arr(i, 3) & "|" & arr(1, 4)
- If d.exists(s) Then
- arr(i, 4) = d(s)
- End If
- For j = 5 To c
- s = arr(i, 3) & "|" & arr(i, 2) & "|" & arr(1, j)
- If d.exists(s) Then
- arr(i, j) = d(s)
- End If
- Next
- Next
- .[a1].Resize(r, c) = arr
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|