Excel Macros in Google Sheets: What Works?

VBA & macros · Updated November 3, 2026

Excel Macros in Google Sheets: What Works?

No: Google Sheets cannot run Excel VBA macros, even when you open an Excel workbook that contains them. You can recreate many routine tasks with Google Sheets macros, which are recorded as Google Apps Script, or rewrite the VBA logic in Apps Script.

What an Excel macro is

An Excel macro is a set of instructions that automates work in a workbook. In desktop Excel, macros are commonly written in Visual Basic for Applications (VBA), Microsoft’s programming language for Office applications. A VBA macro might format a monthly report, move rows between worksheets, create a chart, or interact with Excel features through its object model.

VBA is part of Excel’s environment, not a general-purpose file feature that every spreadsheet program can run. A workbook ending in .xlsm can contain spreadsheet data, formulas, and a VBA project, but another program needs its own compatible VBA execution environment to run that project. Google Sheets does not provide one.

This distinction matters because a workbook can appear to open normally while its automation does not work. The visible cell values and much of the worksheet structure may be available, but that does not mean the macro code has been translated or activated.

What happens when you open an Excel macro workbook

Google Sheets can work with many Microsoft Excel files, including macro-enabled workbooks, but it does not execute their VBA code. Opening or editing a file in Sheets is therefore not a way to run an Excel button, event macro, or keyboard-triggered VBA procedure. Controls tied to VBA may not behave as they do in Excel.

You may encounter an Office file in Google Drive and edit it while retaining its Excel format, or convert it to Google Sheets format. Neither option turns VBA into Apps Script. Conversion can also change features that are specific to Excel, so keep an untouched copy of the original .xlsm file before trying a conversion. If preserving a working VBA project is important, keep using a compatible desktop version of Excel for that workbook.

Do not treat a missing warning or a visible worksheet as proof that the automation transferred. Check important formulas, formatting, named ranges, buttons, and other workbook behavior after moving data. For a business-critical workbook, test on a copy and compare the results with the original in Excel.

How Google Sheets macros work

Google Sheets macros are based on Google Apps Script, a cloud-hosted scripting platform that uses JavaScript. When you record a macro in Sheets, the service creates a function in the spreadsheet’s bound Apps Script project. The function can then replay supported spreadsheet actions. You can also edit the generated script or write a script directly in the Apps Script editor.

This is similar to Excel macros in purpose, but not in programming language or runtime. Apps Script works with Google services, including Sheets, and may request authorization to access data or services. VBA instead uses Excel’s object model and can interact with desktop Office and the local computer in ways that a browser-based Sheets script does not.

Recorded macros are most useful for predictable, repetitive actions within a spreadsheet, such as applying a standard format or carrying out a sequence of supported edits. Recording is not a general-purpose converter: it will not watch an Excel VBA macro and automatically produce an equivalent Apps Script function.

Record and run a macro in Google Sheets

To make a basic macro in a Google Sheets file in a web browser, use the Sheets menu rather than Excel’s Developer tab:

  1. Open the spreadsheet and select Extensions > Macros > Record macro.
  2. Choose whether to use absolute references or relative references, then perform the actions you want recorded. Absolute references repeat actions at the same cell locations; relative references can apply them in relation to the cell you select when running the macro.
  3. Select Save, give the macro a name, and confirm. Sheets stores the recorded function in the spreadsheet’s Apps Script project.
  4. To run it later, select Extensions > Macros and choose its name. When prompted, review and authorize the required access.

For example, recording a sequence that selects a report range, applies a header style, and adjusts number formatting can save repeated menu work. If the next report has a different layout, however, a recorded sequence tied to fixed cells may format the wrong range. That is a signal to edit the script to identify the relevant data dynamically, or to choose a different workflow.

For more control, open Extensions > Apps Script. The script editor lets you inspect and modify the function created by the recorder, add logic such as conditions, and use Apps Script services. A script that makes changes to a spreadsheet should be tested on a copy or with disposable sample data before it is used on an important file.

How to move an Excel macro to Sheets

There is no one-click, reliable VBA-to-Apps-Script conversion. The practical approach is to identify what the macro is meant to accomplish and rebuild that behavior using features available in Sheets.

  • Document the workflow. Note the input cells or sheets, the steps performed, the expected output, and any prompts or edge cases. Do not assume the code alone explains every business rule.
  • Separate spreadsheet work from computer-specific work. Actions such as changing cell values may have a Sheets equivalent. VBA that controls desktop windows, local files, or other Office applications may need a different design or may not be suitable for a browser spreadsheet.
  • Rebuild and test a small part first. Create a Sheets macro for recordable actions, or write Apps Script for logic that needs conditions, loops, or data handling. Compare its output with Excel using representative examples.
  • Review access and sharing. Decide who can run or edit the script, what authorization it needs, and whether the spreadsheet should contain the script at all.

Some tasks may be better handled without a script. A built-in Sheets feature, a formula, a filter, or a template can be easier to maintain than code. If an existing VBA macro depends heavily on Excel-only features, keeping that process in Excel may be safer and less expensive than recreating it.

Key differences between VBA and Apps Script

VBA and Apps Script differ in more than syntax. VBA is commonly used in desktop Excel and can automate Excel’s application-specific features. Apps Script runs in Google’s environment and uses services designed for Google products. A VBA instruction that refers to an Excel range or worksheet will not become valid Apps Script simply by changing the file extension.

The two platforms also have different ways of handling events, permissions, files, and user interfaces. A Sheets script may be able to work with a Google spreadsheet or call another Google service, subject to authorization and platform rules. It cannot simply use VBA’s desktop interfaces to control a local copy of Excel. Likewise, an Excel form or button that invokes VBA should not be expected to become a working Sheets control automatically.

Both platforms can automate repetitive spreadsheet tasks, but they are not interchangeable. When evaluating a migration, compare the result the user needs rather than the lines of code. If the goal is simply to standardize formatting, a recorded Sheets macro may be enough. If the macro performs complex reporting, communicates with external systems, or relies on Excel-specific objects, the replacement may require substantial redesign.

Permissions, safety, and practical limits

Macros and scripts can make changes quickly, so only run code you understand or trust. In Sheets, a script may need authorization before it can access the spreadsheet or other Google services. Read the permission request and confirm that the account and project are appropriate before approving it. A request for access should not be treated as harmless just because the script is attached to a spreadsheet.

Sharing also deserves attention. People with access to a spreadsheet may be able to use its macros, while editing the bound script is a separate capability controlled through the script project and account permissions. Review who can edit the file and its code, especially if the spreadsheet contains confidential information or automates consequential updates. Organizations may also apply administrator settings that affect Apps Script or access to services.

Apps Script is subject to Google’s quotas and service limits, which can vary by account type and can change. A script designed for a small sheet may need a different approach for a very large dataset or frequent automated runs. Check current Apps Script documentation for limits that apply to the services and account in use, and build in testing and error handling rather than assuming an automation will always finish.

Which option should you choose?

Choose based on where the process needs to run and what the existing automation depends on:

  • Keep the workflow in Excel if it relies on VBA, desktop Excel features, or integration with other Office or Windows applications.
  • Use a Sheets macro if the task is a repeatable sequence of supported edits in a Google spreadsheet.
  • Write Apps Script if the workflow needs logic or integration beyond what the recorder can capture, and the Google platform fits the requirement.
  • Use built-in Sheets tools if a formula, filter, template, or other native feature can do the job with less maintenance.

For a team deciding whether to migrate, make a small proof of concept with a copy of the workbook. Include typical data, unusual cases, permissions, and the people who will maintain the solution. The useful comparison is not just whether a script can run, but whether it produces the right result reliably and can be supported over time.

Frequently Asked Questions

Can Google Sheets run VBA macros?
No. Sheets does not execute VBA. Recreate the task with a Google Sheets macro or Apps Script, or run the original workbook in a compatible version of Excel.

Will converting an XLSM file convert its macros?
No. Converting a workbook to Google Sheets does not translate its VBA project into Apps Script. Keep a separate copy of the original file before converting.

Can I record a macro in Google Sheets?
Yes. In a browser, choose Extensions > Macros > Record macro, perform supported actions, and save. The recorded macro is stored as Apps Script.

Can Apps Script replace every Excel macro?
No. It can recreate many spreadsheet workflows, but it uses a different platform and has different capabilities. Code that depends on desktop Excel, VBA forms, or local computer resources may need a redesign or may be better kept in Excel.

Do Google Sheets macros work in Excel?
No. A Sheets macro is Apps Script, not VBA. Excel does not run that script as an Excel macro; an equivalent VBA solution would need to be created separately if the task must also run in Excel.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.