excel表格可以合并嗎怎么設(shè)置合并
日常工作當(dāng)中,會(huì)產(chǎn)生很多Excel文檔,每當(dāng)需要整理的時(shí)候又很難歸類、查詢。這個(gè)時(shí)候就需要把諾干個(gè)Excel文檔,合并到一個(gè)Excel文檔里。不懂的朋友下面讓學(xué)習(xí)啦小編為你帶來(lái)excel2013多個(gè)表格合并的方法。
excel將多個(gè)表格合并的方法
1、把需要合并的excel表格文檔放到同一個(gè)文件夾里
2、新建一個(gè)“數(shù)據(jù)合并.xlsx“文檔
3、打開“數(shù)據(jù)合并.xlsx“文檔,在”Sheet1“工作表的地方右鍵→查看代碼(快捷鍵:“Alt+F11”,盡量選用快捷方式)進(jìn)入到Microsoft Visual Basic for Applications窗口
4、雙擊工程資源管理器里面的sheet1,在右側(cè)的代碼區(qū)粘貼如下代碼:
Sub 合并當(dāng)前目錄下所有工作簿的全部工作表()
Dim MyPath, MyName, AWbName
Dim Wb As Workbook, WbN As String
Dim G As Long
Dim Num As Long
Dim BOX As String
Application.ScreenUpdating = False
MyPath = ActiveWorkbook.Path
MyName = Dir(MyPath & "\" & "*.xls")
AWbName = ActiveWorkbook.Name
Num = 0
Do While MyName <> ""
If MyName <> AWbName Then
Set Wb = Workbooks.Open(MyPath & "\" & MyName)
Num = Num + 1
With Workbooks(1).ActiveSheet
.Cells(.Range("A65536").End(xlUp).Row + 2, 1) = Left(MyName, Len(MyName) - 4)
For G = 1 To Sheets.Count
Wb.Sheets(G).UsedRange.Copy .Cells(.Range("A65536").End(xlUp).Row + 1, 1)
Next
WbN = WbN & Chr(13) & Wb.Name
Wb.Close False
End With
End If
MyName = Dir
Loop
Range("A1").Select
Application.ScreenUpdating = True
MsgBox "共合并了" & Num & "個(gè)工作薄下的全部工作表。如下:" & Chr(13) & WbN, vbInformation, "提示"
End Sub
5、運(yùn)行→運(yùn)行子過(guò)程/用戶窗體(或者直接點(diǎn)擊運(yùn)行按鈕,快捷鍵:F5),即可合并所有Excel表格到”數(shù)據(jù)合并.xlsx“文檔的Sheet1工作表里面
6、完成Excel表格的合并
猜你感興趣: