怎么把EXCEL的一个工作簿中多个工作表的内容合并到一个工作表??
一个工作簿中有38个工作表,怎么把这38个工作表的内容合并到一个新的工作表???怎么用宏啊
--------------------编程问答--------------------
急急急!!一个工作簿中有38个工作表,怎么把这38个工作表的内容合并到一个新的工作表???怎么用宏?
--------------------编程问答--------------------
Private Sub CommandButton1_Click()
Dim tmpSht, srcSht As Worksheet
Dim i, cpyStartRow As Integer
cpyStartRow = 0
For i = 1 To Application.ActiveWorkbook.Worksheets.Count
If i > 1 Then
Set tmpSht = ActiveWorkbook.Worksheets(i)
'' tmpSht.UsedRange.Select
tmpSht.UsedRange.Copy
srcSht.Cells(cpyStartRow, 1).Value = "----------------" & tmpSht.Name & "----------------"
srcSht.Cells(cpyStartRow + 1, 1).Select
srcSht.Paste
cpyStartRow = cpyStartRow + tmpSht.UsedRange.Rows.Count + 1
Else
Set srcSht = ActiveWorkbook.Worksheets(i)
cpyStartRow = srcSht.UsedRange.Row + srcSht.UsedRange.Rows.Count + 1
End If
Next i
End Sub
--------------------编程问答--------------------
楼上已解
--------------------编程问答--------------------
补充:VB , VBA