|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。
- Sub ykcbf() '//2024.6.15
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set Fso = CreateObject("Scripting.FileSystemObject")
- Set sh = ThisWorkbook.Sheets("原料价格预测")
- sh.UsedRange.Clear
- p = ThisWorkbook.Path & ""
- For Each f In Fso.GetFolder(p).Files
- If InStr(f.Name, ThisWorkbook.Name) = 0 Then
- fn = Fso.GetBaseName(f)
- Set wb = Workbooks.Open(f, 0)
- m = m + 1
- With wb.Sheets("原料价格预测")
- If m = 1 Then
- .Cells.Copy sh.[a1]
- sh.Rows(5).Delete
- Else
- r = sh.Cells(Rows.Count, 1).End(xlUp).Offset(1).Row
- .UsedRange.Offset(5).Copy sh.Cells(r, 1)
- End If
- End With
- wb.Close False
- End If
- Next f
- sh.Activate
- Application.ScreenUpdating = True
- MsgBox "合并完毕!"
- End Sub
复制代码
|
|