0

I want to create a macro in Visual Basic that will select all of the Excel files from a folder and put them into a single file. I used a form with a button that will open a window to select the folders.

Here's the button code, here I can only choose the file instead of the folders:

Private Sub importer_Click()
    Dim file As String
    file = Application.GetOpenFilename("excel (*.xlsx),*.xlsx", , "Chose", , True)

    If (LCase(file) <> "Faux" And file <> "0") Then

        liste_elements.AddItem (file)

    End If
End Sub
Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
Ibrahim
  • 79
  • 10

1 Answers1

0

In order to select more than one file you should set the MultiSelect parameter to true.

Read more about it here: Application.GetOpenFilename Method (Excel)

Pawel Czyz
  • 1,651
  • 4
  • 17
  • 21
  • First of all thank you for you answer, yes i know with that method i can select multiple files but i want to select a folder then the program will extract all the files inside the folder into one file. – Ibrahim Jul 14 '18 at 18:36