我有一個帶有116個工作表的Excel文件,我想將它們追加到一個工作表中(「Tab_Appended」)。我試過下面的代碼,它的工作原理。但是,工作表中的列A未粘貼到Tab_Appended - 我必須更改代碼以實現將除標題行以外的所有數據都複製到Tab_Appended?將多個Excel工作表追加到一個工作表中
BTW,我排除了幾張與「案例」是有排除包含字符串「傳奇」,而不是我的所有工作表的上市的所有圖紙更優雅的方式?
Sub SummurizeSheets()
Dim ws As Worksheet
Dim lastRng As Range
Dim lastCll As Range
Application.ScreenUpdating = False
Sheets("Tab_Appended").Activate
For Each ws In Worksheets
Set lastRng = Range("A65536").End(xlUp).Offset(1, 0)
Select Case ws.Name
Case "Tab_Appended", "Legende 1", "Legende 2", "Legende 3", "Legende 4", "Legende 5", "Legende 6", "Legende 7", "Legende 8", "Legende 9", "Legende 10", "Legende 11", "Legende 12", "Legende 13"
'do nothing
Case Else
Set lastCll = ws.Columns(1).Find(What:="*", After:=ws.Range("A1"), SearchDirection:=xlPrevious)
ws.Range("A2:" & lastCll.Address).Copy
Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValues)
'add sheet name before data
lastRng.Resize(lastCll.Row - 1) = ws.Name
End Select
Next ws
Columns("A").SpecialCells(xlBlanks).EntireRow.Delete (xlUp)
Application.ScreenUpdating = True
End Sub
您是否想將來自所有非傳奇*表格的B列數據轉換爲Tab_Apended A:B? – 2013-04-20 17:09:51