Hi experts
I look for way to change this code
Sub ConsolidateWbks()
Dim Pth As String
Dim MstSht As Worksheet
Dim fname As String
Application.ScreenUpdating = False
Pth = "C:\TextFolder\2023\folders\"
Set MstSht = ThisWorkbook.Sheets("sh")
fname = Dir(Pth & "*xls*")
Do While Len(fname) > 0
Workbooks.Open (Pth & fname)
With Workbooks(fname)
.Sheets("sh").Range("A1").CurrentRegion.Copy MstSht.Range("A" & Rows.Count).End(xlUp).Offset(1)
.Close , False
End With
fname = Dir
Loop
End Sub
the code will match SH sheet name for two closed files with open file where import data from closed files in the same sheet , but I look for way to create new sheets names for the MATCH file open where run the macro based on sheets names are in closed files and should create new sheets like this sh1,sh2 and import data for each sheet individually from each closed file individually and no need repeating create sheets every time run the macro just create sheets based on different files names in the folder and should replace data for each sheet when run the macro every time .
I put the result in MATCH file after running sheet how create new sheets and import data from closed files .
thanks