Paul's Programming Notes     Archive     Feed     Github

Open File With Excel Macro


This macro will ask the user to input an excel file, then open that excel file:

Sub RunMacro()
   
Dim vaFiles As Variant
Dim i As Long

vaFiles = Application.GetOpenFilename _
         (FileFilter:="Excel Filer (*.xls),*.xls", _
         Title:="Open File(s)", MultiSelect:=False)

If Not IsArray(vaFiles) Then Exit Sub

With Application
    .ScreenUpdating = False
   
    For i = 1 To UBound(vaFiles)
        Workbooks.Open vaFiles(i)
    Next i
   
    .ScreenUpdating = True
End With

End Sub