Forum Discussion

minhhai91's avatar
minhhai91
Copper Contributor
Jun 30, 2021
Solved

Select all files in a folder automatically

Hello,   I have a code for fussing with several sheets in the same folder by but you have to select the files manually: this is the code I actually have   This is the code i want to ...
  • HansVogelaar's avatar
    HansVogelaar
    Jun 30, 2021

    minhhai91 

    Replace

        With Application.FileDialog(4) ' msoFileDialogFolderPicker
            .InitialFileName = ThisWorkbook.Path
            If .Show Then
                stDossier = .SelectedItems(1) & Application.PathSeparator
            Else
                Beep
                Exit Sub
            End If
        End With

    with a line that specifies the path:

        stDossier = "C:\MyFolder\MySubfolder\"

    The path must end in a backslash \

Resources