VBA Code to Open Excel File from Folder

Open Excel File from Folder with VBA Code

What is it:

This VBA Code will help you browse and Open Excel File from Folder or a directory.

Why:

When you create a program and if you want to provide the user an option to select a particular Excel file and open then this code can be used for the same.

How to Open Excel File from Folder using VBA Code:

Step 1: Open the workbook and press Alt + F11 to insert the code.

Module_Open Excel File from Folder

Step 2: Copy and Paste the below code in the VBA editor window and Save the workbook.



Sub OpenSpecificWorkbook()

Dim xlName As Variant

xlName = Application.GetOpenFilename(FileFilter:=”Excel Workbooks,*.xl*”, Title:=”Choose a Workbook to Open”, MultiSelect:=False)  ‘GetOpenFilename Method activates dialog box

If xlName <> False Then

Workbooks.Open Filename:=xlName

End If

End Sub

Step 3: Insert a Command button in the Excel File or UserForm and assign this Macro.

About Anson

I’m Anson, having versatile experience in Business Process Outsourcing, Finance & Accounting, Information Technology, Operational Excellence & Business Intelligence. I'm currently working in a MNC in Bangalore, India. Learning anything new has always been my passions and if its related to Business and Technology then, I love it. This website/blog is an outcome of my passion towards it and I have been blogging since 2012. Outside business and technology I’m a movie freak who spends hours together watching and learning Cinema.

One Comment

  1. Pingback: Open Excel File from Folder with VBA Code | asK...

Leave a Reply