During a procedure you may wish your user to choose a file to open. This can slow the process of running code down but if you have a moving target this will be essential in getting the right data imported or manipulated via VBA. I have not had to do this very often but a client asked if they could choose a file mid procedure and the following is what I came up with.
The procedure will open a file dialog and you choose the file and it will open. Simple as that.
Option Explicit
Sub OpenFile()
Dim fn As String
Dim fd As Office.FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
fd.AllowMultiSelect = False
fd.Title = "Please select the file."
If fd.Show = True Then
fn = Dir(fd.SelectedItems(1))
End If
Workbooks.Open (fn)
End Sub