excel2003怎么合并工作表
时间:2023-09-30 10:41:25
在excel中,想要合并两个内容相似的工作表,应该怎么设置呢?下面随小编一起来看看吧。
excel合并工作表的步骤
每个文件夹中的工作簿都输入了简单的内容。
在该文件夹中,新建立一个新的excel工作簿文件。重命名为8.
打开新建立的excel工作簿文件8.按Alt+F11或者将鼠标移动到下方工作表名称sheet1上右键,选择查看代码。
在弹出的代码编辑窗口中,输入代码。注意:通过快捷键Alt+F11打开的窗口如下没有直接复制代码的面板,需要点击左上方的工程-VBA project模块,双击sheet1,即可打开代码窗口。而步骤3中的第二种方法可以直接打开代码输入窗口。
在代码窗口中,黏贴下列代码:
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
点击菜单栏运行-运行子过程-用户窗体。关闭代码输入窗口。打开excel工作簿8.可以看到下方已经多了很多新的工作表——此时,我们已经将之前的工作簿中的工作表都复制到了这一新建的工作簿中。
excel合并工作表的
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
风云直播APP取消绑定章鱼TV的具体操作教程
![](https://img.aspxhome.com/file/2023/8/a338657_0s.jpg)
Win11怎么设置免打扰?
![](https://img.aspxhome.com/file/2023/1/a281877_0s.png)
Win7 PNG图标的边缘有阴影想要优化视觉享受如何将其去掉
![](https://img.aspxhome.com/file/2023/29/a254101_0s.jpg)
win7怎么看电脑配置
![](https://img.aspxhome.com/file/2023/3/a293101_0s.png)
Windows7系统不能录音的解决方法
![](https://img.aspxhome.com/file/2023/29/a253926_0s.jpg)
pr如何快速跳到下一个标记点上面?pr怎么跳到下一个标记点教程
![](https://img.aspxhome.com/file/2023/30/a267590_0s.jpg)
微软为Win10一周年更新版14393.222累积更新问题发布修复脚本下载
![](https://img.aspxhome.com/file/2023/28/a243428_0s.png)
向机械硬盘说再见:固态硬盘普及势头越来越猛
![](https://img.aspxhome.com/file/2023/4/a309842_0s.png)
手心输入法好不好?有哪些功能?
![](https://img.aspxhome.com/file/2023/5/a318278_0s.jpg)
手机wps怎样设置表格字体
Win10系统网上邻居看不到其他共享电脑的4个解决方法!
![](https://img.aspxhome.com/file/2023/1/a274136_0s.jpg)
excel 如何设置数据以显示精度进行计算?
![](https://img.aspxhome.com/file/2023/4/a161744_0s.jpg)
u盘启动dos最简单的的小方法
![](https://img.aspxhome.com/file/2023/2/a291417_0s.png)
excel自动筛选的使用教程
Foxmail中怎么将邮件撤回?Foxmail中将邮件撤回的方法
![](https://img.aspxhome.com/file/2023/8/a334608_0s.jpg)
将Word文档转为Excel表格和Excel表格转换成Word文档的图文教程
![](https://img.aspxhome.com/file/2023/4/30014_0s.jpg)
wps怎么快速复制表格相同内容
微软win10如何设置投影
![](https://img.aspxhome.com/file/2023/4/a308785_0s.png)
Win7防火墙无法更改设置提示错误代码0x80070422怎么办
![](https://img.aspxhome.com/file/2023/3/a297264_0s.jpg)