No—Excel macros written in VBA do not run in Google Sheets. You can usually open or import an Excel macro-enabled workbook to work with its spreadsheet data, but converting it to Google Sheets does not convert its VBA code; to automate the sheet in Google’s app, you need to recreate the task with Google Apps Script or a Sheets macro.
What happens when you open an Excel macro workbook
An Excel macro-enabled workbook usually has the .xlsm file extension. It can contain ordinary spreadsheet content—such as values, formulas, formatting, charts, and worksheets—as well as VBA projects, which hold macros and related code. Google Sheets may let you open the file or import its data, but it does not provide an environment for running that VBA project.
It helps to distinguish opening a file from running its automation. Seeing the workbook’s cells in a browser does not mean its buttons, event-triggered procedures, or automated reports will work. A button that calls a VBA procedure may appear in the sheet but do nothing useful in Google Sheets. Likewise, code that runs when a workbook opens in desktop Excel will not automatically run when the file is opened in Sheets.
If you convert the workbook into Google Sheets format, its VBA macros are not converted into working Sheets macros. Treat the converted copy as a spreadsheet, not as a functioning macro-enabled application. Keep the original .xlsm file somewhere safe if you may need to return to Excel or recover its code.
Why VBA and Google Apps Script are different
VBA (Visual Basic for Applications) is Microsoft’s automation language for desktop Office applications, including Excel. Google Sheets uses Google Apps Script, a JavaScript-based platform for automating Google Workspace. Both can automate spreadsheet tasks, but they are different languages with different object models, services, permissions, and ways of interacting with the spreadsheet.
For example, an Excel macro might refer to a worksheet using VBA’s workbook and worksheet objects, then loop through cells and apply formatting. A Sheets script instead uses Apps Script services such as SpreadsheetApp to access a spreadsheet. Translating the idea may be straightforward for a small task, but the VBA code itself is not a script that Sheets can simply interpret.
Automation also connects to different systems. A VBA macro might use Excel-specific features, Windows files, Outlook, or a locally installed add-in. An Apps Script replacement may need different services, permissions, or a different design. So even when the goal is the same—such as sending a summary email—the work is usually a rewrite, not a file conversion.
What usually transfers—and what may not
When a workbook is imported or converted, much of its basic spreadsheet content may be usable: cell values, many common formulas, and familiar formatting. But Excel and Sheets are not identical, so a workbook can need adjustments even apart from its macros. Features that rely on Excel-specific behavior may change, be unavailable, or behave differently after conversion.
Check the parts of the workbook that drive decisions or reports, rather than assuming that a successful import means a perfect conversion. Pay particular attention to:
- VBA procedures and buttons: VBA does not become Apps Script, and controls that depended on it may no longer perform their task.
- Formulas and functions: Some functions, references, or calculation behaviors differ between products. Review important outputs against the original workbook.
- External connections: Links to other files, databases, add-ins, or desktop applications may depend on access that Sheets does not have.
- Workbook features: Complex charts, data models, controls, or specialized Excel features may not have exact equivalents.
For a critical workbook, compare key totals and outputs before and after conversion. A useful check is to run the original process in Excel, record a few known results, and then confirm whether the converted sheet produces equivalent results using its available formulas or replacement automation.
Ways to open or convert an .xlsm file
There are two different goals: viewing or editing the workbook in Google’s environment, and converting it into native Google Sheets format. The exact options shown can depend on how the file is stored and your account, but the general choices are:
- Keep the original Excel file: Store the
.xlsmfile in Drive if you want it available online, while retaining the original file for use in desktop Excel. Storing a file in Drive does not make its VBA run in Sheets. - Open or import it for spreadsheet work: In Google Sheets, use File > Import to select an uploaded workbook and choose an import option. Review the resulting sheet and its formulas; do not expect its VBA automation to operate.
- Convert to Google Sheets: If you want a native Sheets file, use the option to save or convert the workbook as Google Sheets when available. Conversion creates a Sheets version, but it does not translate the Excel macro code into Apps Script.
Keep a separate copy before importing or converting, especially if the workbook is important or contains automation you may need later. Avoid treating a converted file as a replacement for the original until you have checked the data, formulas, and any business process that relied on the macros.
How to replace a VBA macro in Sheets
Start by writing down what the macro actually does, including its inputs, outputs, and any conditions. A long VBA procedure may contain several unrelated tasks; separating them can make it easier to decide which ones need automation and which can be handled with formulas or built-in Sheets features.
For a simple repeated action, Google Sheets can record a macro. In a Google Sheets file, choose Extensions > Macros > Record macro, perform the actions, and save the recording. A recorded Sheets macro is implemented with Apps Script. It is not importing or translating an Excel VBA macro, and recording is most useful for repeatable actions that the recorder can capture.
For more control, choose Extensions > Apps Script to create or edit a script associated with the spreadsheet. Before building a replacement, consider whether a built-in feature, formula, filter, or template can do the job more simply. Scripts may request authorization to access spreadsheet data or other Google services, so review what a script does before approving it.
Test a replacement on a copy with representative data. Confirm not only that it works for the usual case, but also what happens with blank cells, unexpected values, duplicate records, or a second run. If the original macro interacts with desktop files, Outlook, Excel add-ins, or other Windows programs, it may require a redesigned workflow rather than a direct Apps Script equivalent.
When to stay with Excel instead
Google Sheets can be a good fit when people need browser-based collaboration and the workbook’s essential tasks can be handled with Sheets features or Apps Script. Excel is usually the more practical choice when the process depends on extensive VBA, Excel-specific controls, desktop add-ins, or integration with other Windows applications.
There is also a middle ground: keep the working macro-enabled workbook in Excel and share exported or summarized data with collaborators who use Sheets. That can preserve the automation where it is supported while giving others a view or a simpler dataset to work with. Establish which copy is authoritative so that edits made in separate versions do not create conflicting results.
Excel for the web is not a way to run VBA in a browser either. It can open workbooks that contain macros, but VBA macros cannot be created, run, or edited there. If execution of existing VBA is essential, use a compatible desktop version of Excel and test the workbook in that environment.
Common problems and misconceptions
“The workbook opened, so the macro must be working.” Not necessarily. The cells can display correctly even though the automation is unavailable. Try to identify the result the macro was supposed to produce and check whether that result changes when you use the converted file.
“A Sheets macro is the same as an Excel macro.” They serve a similar purpose, but a Sheets macro uses Apps Script, not VBA. It needs to be recorded or written for Sheets and may need different permissions or logic.
“Changing the extension from .xlsm to another format will convert the code.” Renaming a file does not translate its contents. Use the application’s import or conversion options, and expect to rebuild any VBA automation separately.
Another common issue is assuming that a visible button or drawing still has a working assignment after conversion. If a control was connected to a VBA procedure, check it explicitly. Recreate the action using a suitable Sheets mechanism, or use the original workbook in Excel if the task depends on VBA.
Safety when handling macro-enabled workbooks
Macro-enabled files can contain code that performs actions, so only enable or run macros in Excel when you trust the file’s source and understand why the automation is needed. A familiar filename or a workbook stored in Drive is not, by itself, proof that its code is safe. Follow your organization’s security rules, and ask the sender what the macro is meant to do if that is unclear.
Keeping an untouched original is also a practical safeguard. Make a copy before converting, and keep sensitive or regulated data in approved storage. When replacing a macro with Apps Script, review the script and its requested permissions before granting access. These precautions help prevent accidental data loss and make it easier to compare the original process with the new one.
Frequently Asked Questions
Can Google Sheets run VBA macros?
No. Google Sheets does not execute Excel VBA. To automate a Sheets file, use a Sheets macro or write a replacement in Google Apps Script.
Will converting an XLSM file to Google Sheets keep its macros?
No. Conversion does not turn VBA into working Sheets automation. Keep the original .xlsm file if you need its VBA code for Excel.
Can I open an XLSM file in Google Sheets?
You can often import or open its spreadsheet content, depending on the file and available account options. Opening it does not make its VBA macros run, and you should check the converted data and formulas.
Can I use Excel macros in Excel for the web?
Excel for the web can open a workbook containing macros, but it cannot create, run, or edit VBA macros. Use desktop Excel when the workbook’s VBA automation must run.
How do I automate a Google Sheets file?
Use Extensions > Macros > Record macro for suitable recorded actions, or open Extensions > Apps Script to build a script. Neither option automatically imports existing VBA.
Related
- Excel Shortcut to Insert a Row and Shift Cells Down
- Compound Interest Spreadsheet: Build One in Excel Easily
- Power Query: Select Columns and Keep the Fields You Need
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Word VBA: Remove Formatting While Keeping StylesTo remove direct formatting from selected text in Word VBA while keeping its assigned styles, reset both its…
- Excel VBA Now: What Still Works and What Doesn’t in 2026Yes—Excel VBA is still supported in the desktop versions of Excel for Microsoft 365, and it remains useful…
- Excel VBA Find Value in Range: Examples and TipsTo find a value in an Excel range with VBA, use the range’s Find method, then check whether…
- Access VBA Find Text: Methods, Examples, and FixesTo find text in Access VBA, use a DAO recordset’s FindFirst method with a criterion such as [LastName]…
- Excel VBA Copy and Paste a Row: Practical Code GuideTo copy a row with Excel VBA, specify the source and destination worksheet rows and use Copy Destination.…
- Excel VBA UserForm Position on ScreenTo control an Excel VBA UserForm’s position, set its StartUpPosition property to 0 - Manual, then assign its…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.