以下是引用吹水佬在2021-12-11 15:47:12的发言:
感觉用Copy较快
Private Sub CommandButton1_Click()
Dim sh As Worksheet, nRows As Long, nRowCount As Long, nColCount As Long
On Error Resume Next
If Not Worksheets("合并表") Is Nothing Then
Application.DisplayAlerts = False
Worksheets("合并表").Delete
End If
Set sh = Worksheets.Add
sh.Name = "合并表"
nRows = 1
For i = 1 To Sheets.Count
If Sheets(i).Name <> "合并表" Then
nRowCount = Sheets(i).UsedRange.Rows.Count
nColCount = Sheets(i).UsedRange.Columns.Count
Sheets(i).Cells(1, 1).Resize(nRowCount, nColCount).Copy sh.Cells(nRows, 1)
nRows = nRows + nRowCount
End If
Next i
End Sub
感觉用Copy较快
Private Sub CommandButton1_Click()
Dim sh As Worksheet, nRows As Long, nRowCount As Long, nColCount As Long
On Error Resume Next
If Not Worksheets("合并表") Is Nothing Then
Application.DisplayAlerts = False
Worksheets("合并表").Delete
End If
Set sh = Worksheets.Add
sh.Name = "合并表"
nRows = 1
For i = 1 To Sheets.Count
If Sheets(i).Name <> "合并表" Then
nRowCount = Sheets(i).UsedRange.Rows.Count
nColCount = Sheets(i).UsedRange.Columns.Count
Sheets(i).Cells(1, 1).Resize(nRowCount, nColCount).Copy sh.Cells(nRows, 1)
nRows = nRows + nRowCount
End If
Next i
End Sub
感谢版主!这段程序对于一个工作簿中多个工作表的合并确认非常快。如果是多个相同格式的工作簿中的多个工作表的合并,麻烦版主看看有没有好的处理办法。