|
之前找到的代码 只能复制工作簿的第一个sheet,怎么改成所有SHEET
第二个问题是如果文件夹里的文件也可以识别那就太好了
老师们辛苦啦 还望指教 非常感谢
将要合并的文件copy到一个新文件夹(只有这些Excel,且若打开某一文件,数据就能看见——即不用点其他sheet),建一新Excel,也存到该文件夹。仅打开该新Excel,按Alt+F11,点菜单的插入,模块,粘贴如下代码:
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$("")
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
在此界面之间按F5运行此宏,所有表格复制到一个Excel里了。
注意:本操作只合并EXCEL中打开时看到的SHEET。即想要合并哪个sheet,就要在哪个sheet打开时点保存。
|
|