【Office】【Excel】将多个工作表合为一个工作表

在工作表中按下alt+F11打开vba编辑窗口,在菜单栏中选择【插入】=>【模板】,将下面的代码粘贴过去,然后运行即可

点击查看代码
Sub 合并当前工作簿下的所有工作表()
On Error Resume Next
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set st = Worksheets.Add(before:=Sheets(1))
st.Name = "合并"
For Each shet In Sheets:
If shet.Name <> "合并" 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 "已完成"
End Sub



posted @ 2021-11-01 23:42  萌狼蓝天  阅读(1313)  评论(0编辑  收藏  举报