我这儿有代码,合并当前目录下所有工作簿的全部工作表;复制运行试试;
Sub合并当前目录下所有工作簿的全部工作表()
DimMyPath,MyName,AWbName
DimWbAsWorkbook,WbNAsString
DimGAsLong
DimNumAsLong
DimBOXAsString
Application.ScreenUpdating=False
MyPath=ActiveWorkbook.Path
MyName=Dir(MyPath&"\"&"*.xls")
AWbName=ActiveWorkbook.Name
Num=0
DoWhileMyName<>""
IfMyName<>AWbNameThen
SetWb=Workbooks.Open(MyPath&"\"&MyName)
Num=Num+1
WithWorkbooks(1).ActiveSheet
.Cells(.Range("B65536").End(xlUp).Row+2,1)=Left(MyName,Len(MyName)-4)
ForG=1ToSheets.Count
Wb.Sheets(G).UsedRange.Copy.Cells(.Range("B65536").End(xlUp).Row+1,1)
Next
WbN=WbN&Chr(13)&Wb.Name
Wb.CloseFalse
EndWith
EndIf
MyName=Dir
Loop
Range("B1").Select
Application.ScreenUpdating=True
MsgBox"共合并了"&Num&"个工作薄下的全部工作表。如下:"&Chr(13)&WbN,vbInformation,"提示"
EndSub