How to Open a Workbook Using VBA

104 25
    • 1). Press the "Alt" and "F11" keys together to open the VBE.

    • 2). Click on "Insert" on the toolbar and then click on "Module." A blank VBA window will appear.

    • 3). Copy and paste the following code into the VBA window:

      Sub OpenaWorkbook()

      ' OpenaWorkbook Macro

      Workbooks.Open Filename:="C:\Users\John\Book1.xlsx"

      End Sub

    • 4). Replace "C:\Users\John\Book1.xlsx" with the location of the workbook you want to open. For example, if your workbook is on the Desktop and is called "workbook" then change the directory information to"

      "C:\Desktop\workbook.xlsx."

    • 5). Press "F5" to run the macro.

Source...

Leave A Reply

Your email address will not be published.