List folder and Excel Workbooks into sheet2 using msoFileDialogFolderPicker

healey21

Well-known Member
Joined
Dec 22, 2009
Messages
900
Hi All,

Can anyone help with code to list folder path and workbook names using msoFileDialogFolderPicker

I have a project to complete where a user will pick a folder and then I can populate a combo in a userform with the file names.
 
Add a UserForm with a CommandButton and a ComboBox. Then try this CommandButton code:

Code:
Private Sub CommandButton1_Click()
    Dim Folder As String
    Dim FileName As String
    With Application.FileDialog(msoFileDialogFolderPicker)
        .AllowMultiSelect = False
        .Title = "Select Folder"
        If .Show = True Then
            Folder = .SelectedItems(1)
            FileName = Dir(Folder & Application.PathSeparator & "*.xls*")
            With ComboBox1
                .Clear
                Do While Len(FileName) > 0
                    .AddItem FileName
                    FileName = Dir
                Loop
            End With
        End If
    End With
End Sub
 
Upvote 0
Thank you Andrew, this fills the combo perfectly. I am also opening the workbooks so is it possible to show the path as well please.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top