|
代码供参考。。。- Sub ykcbf() '//2024.3.4
- Set fso = CreateObject("scripting.filesystemobject")
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set ws = ThisWorkbook
- p = ThisWorkbook.Path & ""
- On Error Resume Next
- fn = "继续教育支出|住房贷款利息支出|赡养老人支出"
- For Each sht In ws.Sheets
- x = IIf(InStr(fn, sht.Name), 2, 1)
- d(sht.Name) = x
- sht.UsedRange.Offset(x).ClearContents
- Next
- For Each f In fso.GetFolder(p).Files
- If InStr(f, "汇总.xlsx") = 0 Then
- Set wb = Workbooks.Open(f, 0)
- For Each k In d.keys
- Set sht = wb.Sheets(k)
- With sht
- r1 = sht.Find("*", , -4163, , 1, 2).Row
- r = ws.Sheets(k).Find("*", , -4163, , 1, 2).Row
- If r1 > d(k) Then .UsedRange.Offset(d(k)).Copy ws.Sheets(k).Cells(r + 1, 1)
- End With
- Next
- wb.Close 0
- End If
- Next f
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
4
查看全部评分
-
|