Excel表中合并两个Sheet的方法?

按Alt+F11,调出Visual Basic 界面。

在左侧窗口中,右键选择=="插入"---"模块"==:

将如下代码粘贴进去,点击运行按钮,完成数据表合并。

vbnet 复制代码
Sub MergeAllSheetsInThisWorkbook()
On Error Resume Next
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set st = Worksheets.Add(before:=Sheets(1))
st.Name = "merged"
For Each shet In Sheets:
If shet.Name <> "merged" Then
i = st.Range("A" & Rows.Count).End(xlUp).Row + 1
shet.UsedRange.Copy
st.Cells(i, 1).PasteSpecial Paste:=xlPasteAll
End If
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "Done!!!"
End Sub
相关推荐
不坑老师7 小时前
小工具显出大才能——不坑盒子为教育数字化转型贡献“新方案”
microsoft·word·excel·ppt·office
骆驼爱记录7 小时前
Python程序打包全攻略
自动化·word·excel·wps·新人首发
GHL2842710909 小时前
用lingma合并俩个excel
ai·excel
小赖同学啊9 小时前
xmind用例通过excel整理方式(注意!!不是通过python解析ximind文件转化成用例)
开发语言·python·excel
wangkeyen10 小时前
如何用excel拟合两元一次函数?
excel
哈哈你是真的厉害11 小时前
React Native 鸿蒙跨平台开发:实现Excel数据表格
react native·excel·harmonyos
Eiceblue12 小时前
【.NET 开发】通过 C# 实现 Excel 转 JSON
c#·.net·excel
fs哆哆12 小时前
在VB.NET和VBA教程-操作Excel单元格的三个核心问题
ui·.net·excel
hhzz1 天前
EasyPoi的核心映射工具:@Excel注解详解
java·服务器·excel·springboot·easypoi
小妖6661 天前
excel 本地sheet往服务器上粘贴时,表格宽度没有粘过来
excel