Can You Write and Run VBA Macros from an Excel Worksheet?
Question details
The user wants to know where Excel VBA macros must be stored and whether worksheets, hidden sheets, or other workbooks can run them.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A user is converting a Lotus 1-2-3 program that stored named macros in worksheets and wants an equivalent approach in Excel.
- Observed behavior
- The desired setup is to run converted macros from a worksheet or another workbook without creating an unnecessary number of code modules.
Identify what each Lotus macro does and which workbook should contain the converted code. In Excel, make the Developer tab visible through File > Options > Customize Ribbon if it is not already shown.
Store Converted Macros in Excel VBA Code Modules
Use the Visual Basic Editor to create VBA procedures and run them from Excel instead of placing executable VBA in worksheet cells.
VBA procedures belong in standard modules or in worksheet or workbook code modules. Multiple procedures can share one standard module, so you do not need a separate module for every macro.
A hidden worksheet can have its own code module, and hiding the sheet does not by itself disable that code. Code typed into worksheet cells is not executable as standard VBA.
In Excel, select Developer > Visual Basic. In the Project Explorer, select the workbook that will contain the converted macros.
Select Insert > Module for general-purpose procedures. For worksheet or workbook event code, double-click the relevant sheet or ThisWorkbook in the Project Explorer.
Write VBA procedures in the module. To help translate a routine, select Developer > Record Macro, perform the equivalent Excel actions, stop the recording, and review the generated code in the Visual Basic Editor.
Select File > Save As and choose Excel Macro-Enabled Workbook (*.xlsm). To run a public macro in a standard module, select Developer > Macros, choose the macro, and select Run.
To run a macro from a visible worksheet, select Developer > Insert, add a button, and assign the macro when prompted.

Call a VBA Macro from Another Workbook
Use Application.Run when a macro is stored in a different open workbook.
Work with Excel Spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for Microsoft Office formats, making it easy to move everyday spreadsheet work. It does not directly fix Excel VBA issues; check macro support and test converted workbooks before relying on them.

Frequently Asked Questions
Can Excel execute VBA code typed into worksheet cells?
No. Standard VBA must be stored in a code module and edited through Developer > Visual Basic. A worksheet button can call a macro, but the VBA code itself remains in a module.
Can a hidden worksheet contain VBA code?
Yes. A hidden sheet can have a worksheet code module, which you can open from the Visual Basic Editor's Project Explorer. Hiding the sheet does not by itself prevent its code from running.
Do I need a separate VBA module for every Lotus macro?
No. You can put multiple VBA procedures in one standard module. In the Visual Basic Editor, select Insert > Module and add the procedures there.
How can I run a macro stored in another workbook?
Open the workbook containing the public standard-module procedure, then call it from VBA with Application.Run "'TargetWorkbook.xlsm'!MyMacro". The target workbook's macros must be permitted to run.
Can I run Lotus 1-2-3 macros directly in Excel?
Lotus macros generally need to be converted to VBA. Use Developer > Record Macro to capture comparable Excel actions, then review and adapt the generated VBA.




