Excle 多个文档合并为一个 分多个sheet页

鼠标放在sheet页标签上邮件选择查看代码
出现在这里插入图片描述
键入一下代码:
Sub Find()
Application.ScreenUpdating = False
Dim MyDir As String
MyDir = ThisWorkbook.Path & “”
ChDrive Left(MyDir, 1) 'find all the excel files
ChDir MyDir
Match = Dir ( " " ) D o I f N o t L C a s e ( M a t c h ) = L C a s e ( T h i s W o r k b o o k . N a m e ) T h e n W o r k b o o k s . O p e n M a t c h , 0 o p e n A c t i v e S h e e t . C o p y B e f o r e : = T h i s W o r k b o o k . S h e e t s ( 1 ) c o p y s h e e t W i n d o w s ( M a t c h ) . A c t i v a t e A c t i v e W i n d o w . C l o s e E n d I f M a t c h = D i r ("") Do If Not LCase(Match) = LCase(ThisWorkbook.Name) Then Workbooks.Open Match, 0 'open ActiveSheet.Copy Before:=ThisWorkbook.Sheets(1) 'copy sheet Windows(Match).Activate ActiveWindow.Close End If Match = Dir
Loop Until Len(Match) = 0
Application.ScreenUpdating = True
End Sub

点击运行子程序在这里插入图片描述 等待些许时间即可完成。