|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下。。。
- Sub ykcbf() '//2024.8.21
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- With Application.FileDialog(msoFileDialogFilePicker)
- .InitialFileName = ThisWorkbook.Path & ""
- .Title = "请选择对应Excel文件"
- .AllowMultiSelect = False
- .Filters.Clear
- .Filters.Add "Excel文件", "*.xls*"
- If .Show Then f = .SelectedItems(1) Else Exit Sub
- End With
- Set wb = Workbooks.Open(f, 0)
- arr = wb.Sheets("原料测算分析表").UsedRange.Value
- wb.Close 0
- For i = 6 To UBound(arr)
- s = arr(i, 2)
- If s <> Empty Then
- d(s) = Array(arr(i, 8), arr(i, 11))
- End If
- Next
- With Sheets("库存结转价")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 7)
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- If d.exists(s) Then
- arr(i, 6) = d(s)(0)
- arr(i, 7) = d(s)(1)
- End If
- Next
- .[a1].Resize(r, 7) = arr
- .[a1].Resize(r, 7).Borders.LineStyle = 1
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|