|
参与一下。。。- Sub ykcbf() '//2024.1.20
- Set Fso = CreateObject("scripting.filesystemobject")
- Application.ScreenUpdating = False
- Set sh = ThisWorkbook.Sheets("Sheet1")
- st = "财资01资产负债表"
- b = [{"货币资金","固定资产原值","固定资产净值","其他应付款"}]
- ReDim brr(1 To 10000, 1 To 5)
- p = ThisWorkbook.Path & ""
- For Each f In Fso.GetFolder(p).Files
- If f.Name Like "*.xlsx" Then
- fn = Fso.GetBaseName(f)
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets(st)
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .Range("a4:h" & r)
- wb.Close False
- End With
- m = m + 1
- brr(m, 1) = fn
- For j = 1 To UBound(b)
- For i = 2 To UBound(arr)
- If InStr(arr(i, 1), b(j)) Then
- brr(m, j + 1) = arr(i, 4)
- End If
- Next
- For i = 2 To UBound(arr)
- If InStr(arr(i, 5), b(j)) Then
- brr(m, j + 1) = arr(i, 8)
- End If
- Next
- Next
- End If
- Next f
- With sh
- .UsedRange.Offset(1).Clear
- If m > 0 Then
- .[a2].Resize(m, 5) = brr
- .[a2].Resize(m, 5).Borders.LineStyle = 1
- End If
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|