(资料图片仅供参考)
1、Sub 合并当前目录下所有工作簿的全部工作表()Dim MyPath, MyName, AWbNameDim Wb As Workbook, WbN As StringDim G As LongDim Num As LongDim BOX As StringApplication.ScreenUpdating = FalseMyPath = ActiveWorkbook.PathMyName = Dir(MyPath & "" & "*.xls")AWbName = ActiveWorkbook.NameNum = 0Do While MyName <> ""If MyName <> AWbName ThenSet Wb = ***.Open(MyPath & "" & MyName)Num = Num + 1With Workbooks(1).ActiveSheet.Cells(.Range("B65536").End(xlUp).Row + 2, 1) = Left(MyName, Len(MyName) - 4)For G = 1 To Sheets.CountWb.Sheets(G).UsedRange.Copy .Cells(.Range("B65536").End(xlUp).Row + 1, 1)NextWbN = WbN & Chr(13) & Wb.NameWb.Close FalseEnd WithEnd IfMyName = DirLoopRange("B1").SelectApplication.ScreenUpdating = TrueMsgBox "共合并了" & Num & "个工作薄下的全部工作表。
2、如下:" & Chr(13) & WbN, vbInformation, "提示"End Sub。
本文分享完毕,希望对大家有所帮助。
关键词:
全球热资讯!怎么把多个表格合并到一个表格内_怎么把多个表格合并到一个表格
1、Sub合并当前目录下所有工作簿的全部工作表()DimMyPath,MyName,AWbNameDimWb