VBA Code to Open Excel File from Folder

VBA Code to Open Excel File from Folder
Table of Contents

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.

Open Excel File From FolderPin

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.
Picture of Anson Antony
Anson Antony
Anson is a contributing author and founder at www.askeygeek.com. Learning anything new has always been his passion, askeygeek.com is an outcome of his passion for technology and business. He has got a decade of versatile experience in Business Process Outsourcing, Finance & Accounting, Information Technology, Operational Excellence & Business Intelligence. During the tenure, he had worked for organizations like Genpact, Hewlett Packard, M*Modal and Capgemini in various roles and responsibilities. Outside business and technology, he is a movie buff who spends hours together watching and learning Cinema and a Film Maker too!

Leave a Reply

Your email address will not be published. Required fields are marked *

Congratulations!
You Made It,
Don't Close!

Get Up To 60,000 UberTTS Character Credits for Free!!!

This popup won’t show up to you again!!!

UberTTS
Share to...