VBA & Macro Problems

Can You Write and Run VBA Macros from an Excel Worksheet?

Nimra MalikNimra Malik Nov 27, 2026 870 views

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.

Can You Write and Run VBA Macros from an Excel Worksheet?
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the Visual Basic Editor

In Excel, select Developer > Visual Basic. In the Project Explorer, select the workbook that will contain the converted macros.

2
Choose a code module

Select Insert > Module for general-purpose procedures. For worksheet or workbook event code, double-click the relevant sheet or ThisWorkbook in the Project Explorer.

3
Convert the Lotus routines

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.

4
Save and run the macro

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.

5
Add a worksheet control if needed

To run a macro from a visible worksheet, select Developer > Insert, add a button, and assign the macro when prompted.

Store Converted Macros in Excel VBA Code Modules
Excel 4.0 macros are different: Excel 4.0 macro functions are a separate legacy technology, not VBA entered in ordinary worksheet cells. Lotus macros generally need to be converted rather than run directly.
Free Microsoft Office alternative

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.

Open and edit everyday spreadsheet content in a familiar interfaceCompatible with Microsoft Excel formats such as XLSXA lightweight option for reviewing spreadsheets during a Lotus migrationFree tools for common document and spreadsheet tasks
microsoft office alternative - wps office

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.