具體操作方法: 1. 首先將收到的表放在同一個(gè)文件夾下;
具體代碼如下: Sub 把當(dāng)前文件下表格合并生成一個(gè)新的工作簿()Application.ScreenUpdating = FalseDim MyDir As StringMyDir = ThisWorkbook.Path & '\'ChDrive Left(MyDir, 1) ChDir MyDirMatch = Dir$('')DoIf Not LCase(Match) = LCase(ThisWorkbook.Name) ThenWorkbooks.Open Match, 0 ActiveSheet.Copy Before:=ThisWorkbook.Sheets(1)Windows(Match).ActivateActiveWindow.CloseEnd IfMatch = Dir$Loop Until Len(Match) = 0Application.ScreenUpdating = TrueEnd Sub 4. 之后我們會(huì)發(fā)現(xiàn)13個(gè)表格全部生成在一個(gè)工作簿下了,如下圖:
具體代碼如下: Sub 將所有表格的內(nèi)容合并到一個(gè)表當(dāng)中() On Error Resume Next Rows('2:' & Rows.Count).ClearContents Dim wks As Worksheet For Each wks In ThisWorkbook.Worksheets With wks If .Name <> ActiveSheet.Name Then Intersect(.Cells(Rows.Count, 1).End(xlUp).CurrentRegion, .Rows('2:' & Rows.Count)).Copy Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) End If End With Next wks Columns.AutoFitEnd Sub 8. 之后我們會(huì)發(fā)現(xiàn)13個(gè)表格的內(nèi)容全部集成在一相sheet里了,如下圖: 9. 這樣就方便快捷多了,有疑問(wèn)的地方請(qǐng)隨時(shí)詢問(wèn)我! |
|