This opens a file picker dialog, then writes the path of the selected file into the next empty cell in column F:
Sub fooFile()
Dim stFile As String
On Error Resume Next
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Show
stFile = .SelectedItems(1)
End With
If Not stFile = "False" Then
ActiveSheet.Cells(Rows.Count, "F").End(xlUp).Offset(1, 0).Value = Left(stFile, InStrRev(stFile, "\") - 1)
End If
End Sub
Alternatively, instead of browsing for a specific file, you can just pick a folder:
Sub fooFolder()
Dim stFolder As String
On Error Resume Next
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Show
stFolder = .SelectedItems(1)
End With
If Not stFolder = "False" Then
ActiveSheet.Cells(Rows.Count, "F").End(xlUp).Offset(1, 0).Value = stFolder
End If
End Sub
Bookmarks