Hello . I'm using a macro to import the sheets of another files into my excel file. But this macro in addition to the name of the file also imports the extension . How can I modify the macro to not import the extension ??
This is the macro :
Thanks in advance for who will help me.
This is the macro :
Code:
Sub Import_files2()
Dim thisWb As Workbook
Dim files As Variant
Dim i As Integer
Set thisWb = ThisWorkbook
files = Application.GetOpenFilename(FileFilter:="Excel workbooks (*.xls),*.xls", Title:="Seleziona file da importare", MultiSelect:=True)
If Not IsArray(files) Then Exit Sub
For i = 1 To UBound(files)
fpath = files(i)
p = InStrRev(fpath, "\")
wsname = Mid(fpath, p + 1, Len(fpath) - p)
Workbooks.Open fpath
With ActiveWorkbook
.Sheets(1).Copy After:=thisWb.Sheets(thisWb.Worksheets.Count)
thisWb.Sheets(thisWb.Worksheets.Count).Name = wsname
.Close False
End With
Next
MsgBox "Files Imported", vbInformation
End Sub
Thanks in advance for who will help me.