返回列表 上一主題 發帖

[發問] 匯整excel檔案

[發問] 匯整excel檔案

請問
有30個excel檔案
各有sheet1(資料格式相符)
如何在不開啟的狀態下
快速的將此30個sheet , 匯整成一個檔案
謝謝
無止盡的努力上進

Sub 匯整資料()
  Dim a As Workbook, f$
  Dim p$, sh As Worksheet
  Set a = ThisWorkbook
  p = "C:\AAA\"
  f = Dir(p & "*.xls")
  Application.ScreenUpdating = False
  Do While f <> ""
    Workbooks.Open p & f
    For Each sh In Worksheets
    On Error Resume Next
      sh.Copy after:=a.Sheets(a.Sheets.Count)
    Next
    Windows(f).Close True
    f = Dir
  Loop
  Application.ScreenUpdating = True
  Sheet1.Select
  Range("A1").Select
End Sub

TOP

回復 2# rouber590324

這樣節省不少時間
感謝您的回覆
無止盡的努力上進

TOP

        靜思自在 : 有智慧才能分辨善惡邪正;有謙虛才能建立美滿人生。
返回列表 上一主題