I made this for my personal daily jobs. after I search on google, I found the code for merging the multiple workbooks (each has 1 worksheet) into one workbook. and those worksheet have a same name it call "shXetnaXe", so when i try to select the workbooks, it ended up
"shXetnaXe" for sheet(1)
"shXetnaXe(1)" for sheet(2)
"shXetnaXe(2)" for sheet(3)
And so on.
I want those sheets to automatically named as their original selected workbook's name those original names are: "1 sept" "2 sept" "3 sept" , I have try changing it a little bit, but it always fail.
Here's the code
`Sub opensheets()
Dim openfiles
Dim crntfile As Workbook
Set crntfile = Application.ActiveWorkbook
Dim x As Integer
On Error GoTo ErrHandler
Application.ScreenUpdating = False
openfiles = Application.GetOpenFilename _
(FileFilter:="Microsoft Excel Files (*.xls;*.xlsx),*.xls;*.xlsx", _
MultiSelect:=True, Title:="Select Excel file to merge!")
If TypeName(openfiles) = "Boolean" Then
MsgBox "You need to select atleast one file"
GoTo ExitHandler
End If
x = 1
While x <= UBound(openfiles)
Workbooks.Open Filename:=openfiles(x)
Sheets().Move After:=crntfile.Sheets(crntfile.Sheets.Count)
Set rnmsht = Workbook.Open
Sheets(openfiles) = rnmsht
Before:=ActiveWorkbook.Sheets(openfiles.name)
x = x + 1
Wend
Application.DisplayAlerts = False
Sheets(1).Select
ActiveWindow.SelectedSheets.Delete
ExitHandler:
Application.ScreenUpdating = True
Exit Sub
ErrHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub'