excel合并工作簿的教程
相关话题
Excel中经常需要使用到合并工作簿的技巧,工作簿具体该如何进行合并呢?下面是由小编分享的excel合并工作簿的教程,以供大家阅读和学习。
excel合并工作簿教程:
合并工作簿步骤1:将需要合并的excel工作簿文件放置在一个文件夹中。
合并工作簿步骤2:每个文件夹中的工作簿都输入了简单的内容。

合并工作簿步骤3:在该文件夹中,新建立一个新的excel工作簿文件。重命名为8.

合并工作簿步骤4:打开新建立的excel工作簿文件8.按Alt+F11或者将鼠标移动到下方工作表名称sheet1上右键,选择查看代码。

合并工作簿步骤5:在弹出的代码编辑窗口中,输入代码。注意:通过快捷键Alt+F11打开的窗口如下没有直接复制代码的面板,需要点击左上方的工程-VBA project模块,双击sheet1,即可打开代码窗口。而步骤3中的第二种方法可以直接打开代码输入窗口。


合并工作簿步骤6:在代码窗口中,黏贴下列代码:
Sub CombineFiles()
Dimpath As String
DimFileName As String
DimLastCell As Range
DimWkb As Workbook
DimWS As Worksheet
DimThisWB As String
Dim MyDir AsString
MyDir =ThisWorkbook.path & ""
'ChDriveLeft(MyDir, 1) 'find all the excel files
'ChDir MyDir
'Match =Dir$("")
ThisWB =ThisWorkbook.Name
Application.EnableEvents = False
Application.ScreenUpdating = False
path =MyDir
FileName =Dir(path & "*.xls", vbNormal)
Do UntilFileName = ""
If FileName <> ThisWB Then
Set Wkb = Workbooks.Open(FileName:=path & ""& FileName)
For Each WS In Wkb.Worksheets
Set LastCell = WS.Cells.SpecialCells(xlCellTypeLastCell)
If LastCell.Value = "" And LastCell.Address = Range("$A$1").AddressThen
Else
WS.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
End If
Next WS
Wkb.Close False
End If
FileName = Dir()
Loop
Application.EnableEvents = True
Application.ScreenUpdating = True
Set Wkb =Nothing
Set LastCell= Nothing
End Sub

合并工作簿步骤7:点击菜单栏运行-运行子过程-用户窗体。关闭代码输入窗口。打开excel工作簿8.可以看到下方已经多了很多新的工作表——此时,我们已经将之前的工作簿中的工作表都复制到了这一新建的工作簿中。


看了excel合并工作簿的教程还看了:
1.excel2007工作簿合并的教程
2.如何合并excel文件的教程
3.如何将两个excel表合并的教程
4.excel多个表格合并的教程
5.如何把多个excel合并的方法
6.excel表格合并工作表的教程
7.Excel2010怎么合并工作表
excel合并工作簿的教程的评论条评论