|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。
- Sub ykcbf() '//2024.11.10
- Application.ScreenUpdating = False
- Set fso = CreateObject("Scripting.FileSystemObject")
- p = ThisWorkbook.Path & ""
- Set sh = ThisWorkbook.Sheets("主表")
- n = 3
- For Each f In fso.GetFolder(p).Files
- If f.Name Like "*历史数据*" Then
- n = n + 3
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets("主表")
- sh.Cells(2, n - 2) = Mid(.[a4].Value, 7, 8)
- Set Rng = .[d10:d50]
- Rng.Copy sh.Cells(4, n - 2)
- End With
- wb.Close 0
- With sh
- .Columns(n).NumberFormatLocal = "0.00"
- For i = 4 To 50
- .Cells(i, n).Value = Val(.Cells(i, n - 1).Value) + Val(.Cells(i, n - 2).Value)
- Next
- End With
- End If
- Next f
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|