如何把多个相同格式的Excel表格数据快速的合并到一张表格中
1个回答
展开全部
用vba吧,用下面的代码就可以
Sub 合并含有表头的工作表()
x = 0
For i = 1 To Worksheets.Count
If Sheets(i).Name = "合并" Then x = 1
Next i
If x = 0 Then Set sh = Worksheets.Add: sh.Name = "合并": Sheets("合并").Move after:=Sheets(Sheets.Count) Sheets("合并").Activate
Sheets("合并").Cells.Clear
For j = 1 To Worksheets.Count - 1
If j = 1 Then
Sheets(j).UsedRange.Offset(0, 0).Copy Sheets("合并").[a65536].End(xlUp).Offset(0, 0)
Else
Sheets(j).UsedRange.Offset(1, 0).Copy Sheets("合并").[a65536].End(xlUp).Offset(1, 0)
End If
Next j
MsgBox "合并完成!"
End Sub
Sub 合并含有表头的工作表()
x = 0
For i = 1 To Worksheets.Count
If Sheets(i).Name = "合并" Then x = 1
Next i
If x = 0 Then Set sh = Worksheets.Add: sh.Name = "合并": Sheets("合并").Move after:=Sheets(Sheets.Count) Sheets("合并").Activate
Sheets("合并").Cells.Clear
For j = 1 To Worksheets.Count - 1
If j = 1 Then
Sheets(j).UsedRange.Offset(0, 0).Copy Sheets("合并").[a65536].End(xlUp).Offset(0, 0)
Else
Sheets(j).UsedRange.Offset(1, 0).Copy Sheets("合并").[a65536].End(xlUp).Offset(1, 0)
End If
Next j
MsgBox "合并完成!"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询