(1)以下代码适用于并列的多个文件夹内分别含有一个excel文件的情况,且后缀名为.xlsx,其他格式可修改红色字体。 (2)工作表合并后按文件夹名称排列,所以文件夹需先按顺序重命名,如00、01、02...,个位处的0不可省略,否则1后面跟的是11。 (3)在多个文件夹外的大文件夹中新建excel文件,按下ALT+F11,打开VBE窗口,单击插入——模块,复制下面代码,并运行。 Sub CombineFiles() Dim path As String Dim FileName As String Dim LastCell As Range Dim Wkb As Workbook Dim WS As Worksheet Dim ThisWB As String Dim fc, f1, fs Dim MyDir As String Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder(ThisWorkbook.path) Set fc = f.SubFolders For Each f1 In fc MyPath = f & "\" & f1.Name