Hello from the time I'm using a macro that choosing the directory I care all the files into one Excel file . But now I have to import specific files and not all those in the folder as I did before . I did some research and saw that I can choose the files with " multiselect " but I can not understand how the macro should be modified. This is the macro I use now :
Sorry for my english.
I hope someone can help me . Thank you.
Code:
Sub COPIA_Files()
Set objFSO = CreateObject("Scripting.FileSystemObject")
InitialFoldr$ = "C:\" '<<< Startup folder
With Application.FileDialog(msoFileDialogFolderPicker) 'User input for folder to look at
.InitialFileName = Application.DefaultFilePath & "\"
.Title = "Please select a folder to list Files from"
.InitialFileName = InitialFoldr$
.Show
If .SelectedItems.Count = 0 Then Exit Sub
mfolder = .SelectedItems(1) & "\"
End With
Dim nomeFile As String
Dim wb As Workbook
Dim ws As Worksheet
nomeFile = Dir(mfolder)
Do While nomeFile <> ""
If nomeFile <> ThisWorkbook.Name Then
Set wb = Application.Workbooks.Open(mfolder & nomeFile)
Set ws = wb.Worksheets(1)
ws.Name = Left(nomeFile, Len(nomeFile) - 4)
ws.Copy After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)
wb.Close False
End If
nomeFile = Dir
Loop
msgbox "Files Importati", vbInformation
main
End Sub
Sorry for my english.
I hope someone can help me . Thank you.