Tuesday, February 5, 2013

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

No comments:

Post a Comment