Sub 转移数据()
On Error Resume Next '忽略错误继续执行VBA代码,避免出现错误消息
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim s, i, k, wb As Workbook, ws As Worksheet, rng As Range
Sheet1.[A2:AR10000].Clear
s = Dir(ThisWorkbook.Path & "\" & "*.xlsx")
Do
If s <> ThisWorkbook.Name Then
Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & s)
For Each ws In wb.Sheets
If ThisWorkbook.Sheets("库存数据").[A1] = "" Then
ws.Cells.Copy ThisWorkbook.Sheets("库存数据").[A1]
Else
ws.Range("A2", ws.Cells(ws.Range("A1").CurrentRegion.Rows.Count, ws.Range("A1").CurrentRegion.Columns.Count)).Copy ThisWorkbook.Sheets("库存数据").Cells(ThisWorkbook.Sheets("库存数据").Range("A1").CurrentRegion.Rows.Count + 1, 1)
End If
Next ws
wb.Close
End If
s = Dir
Loop Until s = ""
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
获取工作簿下所有工作簿内每个工作表数据汇总到指定工作表
最新推荐文章于 2023-10-13 22:15:07 发布