Folder picker - list what was chosen?

TheWennerWoman

Active Member
Joined
Aug 1, 2019
Messages
303
Office Version
  1. 365
Platform
  1. Windows
Hello, I am trying to populate a cell (named range) with what the user has selected but I don't seem to be able to get this working.

Any pointers appreciated as always.

Code:
Sub status_folder()
Dim fldr As FileDialog
Dim sItem As String
Dim fileSaveName As String
Dim file_4 As String


Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
    With fldr
        .Title = "Select a folder to save Policy Status file to"
        .AllowMultiSelect = False
        .InitialFileName = "O:\Finance\"
        If .Show <> -1 Then Range("file_4").Value = .SelectedItems(1)

        sItem = .SelectedItems(1)
        GoTo NextCode
        'End If
    End With
NextCode:
        Set fldr = Nothing
          
 
    
file_4 = Range("file_4").Value

End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Could you post the solution, in case it helps others, please? (you can then mark it as the answer)
 
Upvote 0
Could you post the solution, in case it helps others, please? (you can then mark it as the answer)
Code:
Sub SelectFolder()

Dim FldrPicker As FileDialog
Dim myFolder As String


'Have User Select Folder to Save to with Dialog Box
  Set FldrPicker = Application.FileDialog(msoFileDialogFolderPicker)

  With FldrPicker
    .Title = "Select A Target Folder"
    .AllowMultiSelect = False
    If .Show <> -1 Then Exit Sub 'Check if user clicked cancel button
    myFolder = .SelectedItems(1) & "\"
  End With
 
Range("file_4").Value = myFolder
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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