No. Excel macros written in VBA do not run in Google Sheets, and converting an Excel workbook does not automatically translate its VBA code into a working Sheets macro. You can often recreate the same task with Google Sheets macros, which use Google Apps Script, but the code and sometimes the workflow must be adapted.
Why Excel and Google Sheets macros are different
An Excel macro is commonly a procedure written in Visual Basic for Applications (VBA). VBA is designed to work with Excel’s object model: it can manipulate workbooks, worksheets, cells, charts, and other Office features. Depending on the code, it may also rely on Windows-specific components, files, or other applications.
Google Sheets uses Apps Script instead. Apps Script is based on JavaScript and provides services for working with Sheets and other Google products. The two systems can automate similar jobs, but they do not share a programming language, runtime, or set of application commands. A VBA instruction that refers to an Excel worksheet, for example, is not something Sheets can execute as-is.
That distinction matters even when a spreadsheet looks nearly identical in both programs. Formatting, formulas, and data may transfer while the automation behind a button or workbook event does not. A workbook that depends on a macro to calculate, clean, or export data can therefore appear intact but stop performing an important step after a move to Sheets.
What happens to an Excel macro when you open or convert a file
Google Sheets can work with many Microsoft Excel files, including files that have not been converted to Google’s native format. That compatibility does not mean Sheets can execute the workbook’s VBA. Opening an Excel file in a browser or converting it to a Google Sheets file does not make its Excel macro operational in Sheets.
Conversion is a change of file format and supported features, not a VBA-to-Apps-Script translator. You should not expect a macro button, keyboard shortcut, or workbook event to keep doing its original job. Some workbook features can also behave differently or be unsupported after conversion, so check the converted file rather than assuming every element survived.
Keep an untouched copy of the original macro-enabled workbook, usually an .xlsm file, before converting or experimenting. If the automation is business-critical, test a representative copy and verify both the data and the required workflow. If colleagues still need the VBA version, maintain a separate version for Excel instead of treating the converted Sheets file as a replacement.
What Google Sheets macros can do
Sheets macros are saved Apps Script functions. They can automate supported actions in a spreadsheet, such as applying formatting, arranging data, or repeating a sequence of edits. The built-in recorder is a useful way to start when the task consists mainly of actions that can be performed in the Sheets interface.
To record one in a browser, open the spreadsheet and choose Tools > Macros > Record macro. Perform the actions you want to repeat, stop the recording, then name and save the macro. Sheets creates an Apps Script function for it. You can run saved macros from the Extensions > Macros menu; the generated script can also be reviewed and edited through Extensions > Apps Script.
The recorder does not reproduce every possible Excel macro feature, and a recorded sequence may need adjustment if the sheet layout changes. For more involved automation, Apps Script lets an author write logic directly, use spreadsheet services, and—in eligible cases—connect with other Google services. That is a rewrite or redesign, however, not a way to run the original VBA.
How to decide whether to rebuild a macro
Start by identifying the result the macro is supposed to produce, not by translating each VBA line mechanically. A short macro that formats a report may be straightforward to recreate. A large application-like workbook with forms, many event handlers, or links to local files may need substantial development or may be better kept in Excel.
- List the user’s steps: Record what someone does before and after running the macro, including any manual checks or saved outputs.
- Identify dependencies: Note Excel-specific features, external files, add-ins, Windows components, email actions, and workbook events used by the VBA.
- Check the destination: Confirm that the required Sheets features and Apps Script services are available to the intended account and organization.
- Estimate the rewrite: Compare the cost and maintenance of rebuilding with keeping the process in Excel or changing the workflow.
- Test with realistic data: Verify edge cases, permissions, output files, and results before relying on the new automation.
A useful example is a macro that removes blank rows and applies a consistent header style. Those actions may be recreated with a recorded macro or a short Apps Script. By contrast, a macro that controls an Excel add-in, reads a particular folder on a Windows computer, or automates another desktop program cannot simply be transferred by recording the same clicks in Sheets.
Typical migration steps
If the task suits Sheets, treat the move as a small software project. Preserve the original, build a native Sheets version, and compare its output with the Excel workflow. A practical sequence is:
- Make a copy: Keep the source workbook unchanged and use a test copy for conversion.
- Convert and inspect: Open or convert the copy in Sheets, then check formulas, formatting, charts, named ranges, and data validation that the process relies on.
- Try the recorder: Use Tools > Macros > Record macro for repeatable interface actions that Sheets can record.
- Adapt the script: Use Extensions > Apps Script to inspect the generated function or write a replacement for logic the recorder cannot capture.
- Authorize and test: Run it with the appropriate account, review any permission request, and compare its results against known examples.
- Document and share: Explain how to run it, what access it requires, and who is responsible for maintaining it.
For a migration involving many VBA procedures, map each macro to its purpose and priority. It may be more efficient to rebuild only the procedures users still need than to reproduce every feature in an old workbook.
Important limitations and common problems
Some VBA features have no direct one-to-one equivalent in Apps Script. Excel user forms, event-driven code, COM add-ins, and Windows file-system operations are examples that may require a different design. Apps Script can offer alternatives, but the available services, permissions, and execution environment differ from desktop Excel.
Automation can also fail for reasons unrelated to translation. A script may refer to a tab name that has changed, expect a particular range to contain data, or run under an account that lacks access to a file. A recorded macro may use fixed cell positions, so inserting rows or changing the layout can make it act on the wrong cells. Test how the process behaves when data is missing, a sheet is renamed, or the file is copied.
Apps Script has usage limits and authorization requirements that differ from VBA. Limits can depend on the account and the service being used, and Google may change them. If a task handles many records or runs on a schedule, check the current Apps Script documentation and test its expected workload before depending on it.
Sharing, permissions, and safety
A Sheets macro is connected to Apps Script, so sharing the spreadsheet and controlling script access deserve attention. Running a script may prompt the user to authorize access to Sheets or other Google services. The requested permissions depend on what the script does. Users should understand why access is requested and avoid running scripts from sources they do not trust.
For a shared workplace file, confirm that the intended users can run the automation and access any referenced documents or services. Organization administrators may restrict Apps Script or particular services. A macro that works for its creator may not work for a colleague who has different permissions, so test with the actual sharing arrangement and explain any authorization steps.
Before changing or running unfamiliar automation, retain a backup and review the code or have a qualified person review it. This is especially important if the script edits or deletes data, sends messages, or accesses information beyond the spreadsheet. Google Sheets changes can often be recovered through version history, but a backup and careful testing are safer than relying on recovery after an error.
When Excel is the better choice
Stay with Excel when the macro depends on VBA features that are central to the workflow, when users need a particular Excel add-in, or when the automation interacts with local Windows resources. Excel for Microsoft 365 on Windows can run VBA macros in desktop Excel; Excel for the web does not create, run, or edit VBA macros, although it can open a workbook that contains them.
Google Sheets is a better fit when browser-based collaboration is important and the needed automation can be built with Apps Script or replaced with built-in Sheets features. Some repetitive tasks may not need a macro at all: formulas, filters, dropdowns, pivot tables, or conditional formatting can be easier to maintain. Choosing the simplest tool that meets the requirement avoids turning a spreadsheet into an unnecessary software project.
Frequently Asked Questions
Can I run a VBA macro in Google Sheets?
No. Google Sheets does not execute Excel VBA. Recreate the needed behavior with Apps Script or keep using desktop Excel for that macro.
Will converting an XLSM file keep its macros working?
No. Conversion does not turn VBA into Apps Script, and the original macro will not run as a Sheets macro. Keep a copy of the original file and inspect the converted spreadsheet’s other features.
Does Google Sheets have its own macros?
Yes. Sheets can record actions as Apps Script functions and lets users run or edit those functions. They are Google Sheets macros, not Excel VBA macros.
Can I convert VBA to Apps Script automatically?
There is no general conversion that makes arbitrary VBA code run unchanged in Sheets. The replacement usually needs to be designed and written for Apps Script, taking account of the original macro’s dependencies.
Can a Google Sheets macro run in Excel?
Not as an Excel VBA macro. Apps Script is designed for Google’s environment; an Excel version of the automation would need to be implemented separately, typically in VBA or another suitable Excel tool.
Related
- Excel Time Format Without Seconds: How to Set It
- Excel Time Format: Show Hours and Minutes Only Correctly
- Excel Time Difference in Seconds: How to Calculate
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Gorilla Copy and Paste VBA: Excel Methods and ExamplesThere is no standard Excel VBA command or feature called Gorilla; if you mean copying and pasting cells…
- Excel VBA: How to Open a WorkbookTo open a workbook with VBA, call Workbooks.Open and give it the file’s full path. For example, Set…
- Copy and Paste a Range in Excel VBA: Methods and ExamplesIn Excel VBA, copy a range with the Range.Copy method and its Destination argument; for example, identify a…
- Excel VBA: Delete the Active Row SafelyTo delete the active row with Excel VBA, use ActiveCell.EntireRow.Delete; this removes the entire worksheet row containing the…
- Excel VBA: Copy a Worksheet and Rename ItTo copy a worksheet and rename the copy with VBA, use the worksheet’s Copy method, then set the…
- Microsoft Excel VBA For Loops: Syntax and ExamplesIn Microsoft Excel VBA, a For...Next loop repeats instructions a set number of times, while For Each...Next repeats…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.