關(guān)于多個表格怎么合并到一個,多個表格如何合并到一個表格這個問題很多朋友還不知道,今天小六來為大家解答以上的問題,現(xiàn)在讓我們一起來看看吧!
1、合并方法如下:把需要合并的excel表格文檔放到同一個文件夾里新建一個“數(shù)據(jù)合并.xlsx“文檔打開“數(shù)據(jù)合并.xlsx“文檔,在”Sheet1“工作表的地方右鍵→查看代碼(快捷鍵:“Alt+F11”,盡量選用快捷方式)進(jìn)入到Microsoft Visual Basic for Applications窗口雙擊工程資源管理器里面的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 = ***.Name?Num = 0?Do While MyName <> ""?If MyName <> AWbName Then?Set Wb = ***.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) & ***.Name?Wb.Close False?End With?End If?MyName = Dir?Loop?Range("A1").Select?Application.ScreenUpdating = True?MsgBox "共合并了" & Num & "個工作薄下的全部工作表。
2、如下:" & Chr(13) & WbN, vbInformation, "提示"?End Sub運(yùn)行→運(yùn)行子過程/用戶窗體(或者直接點(diǎn)擊運(yùn)行按鈕,快捷鍵:F5),即可合并所有Excel表格到”數(shù)據(jù)合并.xlsx“文檔的Sheet1工作表里面完成Excel表格的合并。
本文分享完畢,希望對大家有所幫助。
標(biāo)簽:
免責(zé)聲明:本文由用戶上傳,如有侵權(quán)請聯(lián)系刪除!