Skip to content

Instantly share code, notes, and snippets.

@JHerseth
Created February 28, 2017 19:44
Show Gist options
  • Save JHerseth/c7ce976f46b36f75dacff91b63c27432 to your computer and use it in GitHub Desktop.
Save JHerseth/c7ce976f46b36f75dacff91b63c27432 to your computer and use it in GitHub Desktop.
Sub ChooseFile()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
'get the number of the button chosen
Dim FileChosen As Integer
FileChosen = fd.Show
If FileChosen <> -1 Then
'didn't choose anything (clicked on CANCEL)
MsgBox "You chose cancel"
Else
'display name and path of file chosen
Dim SelectedFile As String
SelectedFile = fd.SelectedItems(1)
End If
Call WritePath(SelectedFile)
End Sub
Sub WritePath(file As String)
'
' Macro2 Macro
'
'
With Sheets("Sheet1")
LastRow = .Range("A" & .Rows.Count).End(xlUp).Row + 1
End With
Cells(LastRow, 1).Formula = "='" + file & "'!" & Cells(2, 7).Address
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment