利用宏命令:
Sub 合并工作表() Dim ws As Worksheet
Dim targetSheet As Worksheet
Dim lastRow As Long
Set targetSheet = ThisWorkbook.Worksheets.Add
targetSheet.Name = “合并结果”
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> targetSheet.Name Then
lastRow = targetSheet.Cells(targetSheet.Rows.Count, 1).End(xlUp).Row
If lastRow = 1 And IsEmpty(targetSheet.Cells(lastRow, 1)) Then lastRow = 0
ws.UsedRange.Copy targetSheet.Cells(lastRow + 1, 1)
End If
Next ws
MsgBox “工作表合并完成!”
End Sub
当然,添加宏命令要在开发者工具那里,要设置才能看到开发者工具菜单。
没有评论