Hi Guy's,
First up I want to apologise, I know this is probably very simple but I haven't worked with VBA in quite a while.
I appreciate any help you can provide in advance.
Basically I want to select an excel file from explorer and then return the full file path into a cell in my current excel workbook i.e. A1.
I'm using the below code which allows me to search/select the file but I'm stumped on how to get it to return the full file path into A1.
Many Thanks
David
Sub browseFilePath()
On Error GoTo err
Dim fileExplorer As FileDialog
Set fileExplorer = Application.FileDialog(msoFileDialogFilePicker)
fileExplorer.AllowMultiSelect = False
With fileExplorer
If .Show = -1 Then
[filePath] = .SelectedItems.Item(1)
Else
MsgBox "You have cancelled the dialogue"
[filePath] = ""
End If
End With
err:
Exit Sub
End Sub
First up I want to apologise, I know this is probably very simple but I haven't worked with VBA in quite a while.
I appreciate any help you can provide in advance.
Basically I want to select an excel file from explorer and then return the full file path into a cell in my current excel workbook i.e. A1.
I'm using the below code which allows me to search/select the file but I'm stumped on how to get it to return the full file path into A1.
Many Thanks
David
Sub browseFilePath()
On Error GoTo err
Dim fileExplorer As FileDialog
Set fileExplorer = Application.FileDialog(msoFileDialogFilePicker)
fileExplorer.AllowMultiSelect = False
With fileExplorer
If .Show = -1 Then
[filePath] = .SelectedItems.Item(1)
Else
MsgBox "You have cancelled the dialogue"
[filePath] = ""
End If
End With
err:
Exit Sub
End Sub