Siga-nos

Subscreva a newsletter

GO UP

How To Merge Multiple Excel Files May 2026

import pandas as pd import glob path = "C:\YourFolder\" files = glob.glob(path + "*.xlsx")

Do While Filename <> "" Set wb = Workbooks.Open(FolderPath & Filename) LastRow = MainWB.Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row + 1 wb.Sheets(1).UsedRange.Copy MainWB.Sheets(1).Range("A" & LastRow) wb.Close SaveChanges:=False Filename = Dir Loop End Sub how to merge multiple excel files

df_list = [] for file in files: df = pd.read_excel(file) df_list.append(df) import pandas as pd import glob path =

Sub MergeAllWorkbooks() Dim FolderPath As String Dim Filename As String Dim wb As Workbook Dim MainWB As Workbook Dim LastRow As Long Set MainWB = ThisWorkbook FolderPath = "C:\YourFolderPath\" ' Change this Filename = Dir(FolderPath & "*.xlsx") how to merge multiple excel files