按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