VBA & Macro Problems

How to Pass VBA Variables Between Excel Workbooks and PERSONAL.XLSB

John WilsonJohn Wilson Nov 2, 2026 870 views

Question details

The user needs to share variables defined in an active Excel workbook with a macro stored in the PERSONAL.XLSB workbook without redefining them.

How to Pass VBA Variables Between Excel Workbooks and PERSONAL.XLSB
Product
Microsoft Excel
Device & OS
not provided
Scenario
Running a global macro from PERSONAL.XLSB that requires dynamic data or variable values generated in the currently active workbook.
Observed behavior
Variables declared as Public in a standard Excel workbook return empty or cause errors when accessed from PERSONAL.XLSB because Public variables only have project-level scope, not application-wide scope.
Before you start

Ensure your PERSONAL.XLSB file is created, unlocked in the VBA Editor, and that your Excel Trust Center settings allow macros to execute.

Solution 1Recommended

Pass Variables as Parameters using Application.Run

The most reliable way to pass values across different VBA projects is by supplying them as arguments to the Application.Run method.

Because Public variables are scoped exclusively to the specific VBA project where they are declared, they cannot be natively read across different workbooks. By leveraging the Application.Run method, you can trigger the target macro in PERSONAL.XLSB and push the necessary variables directly into it as parameters.

1
Modify the receiving macro in PERSONAL.XLSB

Open the VBA Editor (ALT + F11), locate your PERSONAL.XLSB project, and update the macro to accept parameters. For example: Sub TEXAS_Update(strName As String).

2
Execute the macro from the source workbook

In your main workbook's VBA module, trigger the macro and pass the variable by writing: Application.Run "PERSONAL.XLSB!TEXAS_Update", yourVariableValue.

3
Handle multiple variables

If you have a few variables, you can pass multiple arguments separated by commas. For example: Application.Run "PERSONAL.XLSB!TEXAS_Update", var1, var2, var3.

Pass Variables as Parameters using Application.Run
Application.Run Argument Limit: The Application.Run method allows you to pass up to 30 arguments at once, making it suitable for sharing multiple values.
Free Microsoft Office alternative

Looking for a Lightweight Office Alternative for Your Spreadsheets?

If managing complex VBA configurations and global workbooks like PERSONAL.XLSB becomes cumbersome, consider WPS Office. It provides a robust, lightweight, and highly compatible spreadsheet application that handles complex formulas and everyday macro workflows with ease.

  1. 1. Download the software: Visit the official WPS Office website to download the free installation package.
  2. 2. Install and launch: Run the installer and follow the simple on-screen instructions to set up the suite on your computer.
  3. 3. Open existing workbooks: Launch WPS Spreadsheet and seamlessly open your existing Excel files to continue your work without missing a beat.
Seamless format compatibility with Microsoft Excel (.xlsx, .xlsm, .xls)Supports daily spreadsheet automation and data processing tasksFamiliar user interface ensuring a zero learning curve for Excel usersLightweight architecture for faster loading of large datasets
microsoft office alternative - wps office

Frequently Asked Questions

Why does my Public variable return empty in PERSONAL.XLSB?

In VBA, variables declared as Public have project-level scope rather than application-level scope. This means they are only accessible within the specific workbook where they are defined, which is why PERSONAL.XLSB sees them as empty unless explicitly passed.

Can I use ActiveWorkbook in PERSONAL.XLSB without passing variables?

Yes. If your macro in PERSONAL.XLSB simply needs to read standard properties like the workbook name or data from the active sheet, you can use ActiveWorkbook directly in your code without passing it as a parameter, provided the target workbook remains active.

What is the maximum number of parameters I can pass with Application.Run?

You can pass up to 30 arguments to a macro using the Application.Run method in Excel VBA. If you have dozens of variables, consider grouping them in a custom class, a custom type, or storing them in a dedicated worksheet range.