Excel多个sheet合并成一个sheet,只保留一行表头
作者:互联网
Sub hb()
Dim bt, i, r, c, n, first As Long
bt = 1 '表头行数,多行改为对应数值
Cells.Clear
For i = 1 To Sheets.Count
If Sheets(i).Name <> ActiveSheet.Name Then
If first = 0 Then
c = Sheets(i).Cells(1, Columns.Count).End(xlToLeft).Column
Sheets(i).Range("A1").Resize(bt, c).Copy Range("A1")
n = bt + 1: first = 1
End If
r = Sheets(i).Cells(Rows.Count, "A").End(xlUp).Row
Sheets(i).Range("A" & bt + 1).Resize(r - 1, c).Copy Range("A" & n)
n = n + r - bt
End If
Next
MsgBox "当前工作簿下的全部工作表已经合并完毕!", vbInformation, "提示"
End Sub
标签:Count,End,Cells,Excel,表头,bt,Range,Sheets,sheet 来源: https://www.cnblogs.com/april6/p/14763025.html