大家好,小乐来为大家解答以上的问题。多个工作表的数据汇总,excel多个工作表数据汇总这个很多人还不知道,现在让我们一起来看看吧!
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 = ***.NameNum = 0Do While MyName <> ""If MyName <> AWbName ThenSet Wb = ***.Open(MyPath & "" & MyName)Num = Num + 1With Workbooks(1).ActiveSheet.Cells(.Range("A65536").End(xlUp).Row + 2, 1) = Left(MyName, Len(MyName) - 4)For G = 1 To Sheets.CountWb.Sheets(G).UsedRange.Copy .Cells(.Range("A65536").End(xlUp).Row + 1, 1)NextWbN = WbN & Chr(13) & ***.NameWb.Close FalseEnd WithEnd IfMyName = DirLoopRange("A1").SelectApplication.ScreenUpdating = TrueMsgBox "共合并了" & Num & "个工作薄下的全部工作表。
2、如下:" & Chr(13) & WbN, vbInformation, "提示"End Sub。
本文到此分享完毕,希望对大家有所帮助。
免责声明:本文由用户上传,如有侵权请联系删除!