Yes, you can move an Excel macro workflow to Google Sheets, but you generally cannot run its VBA code there unchanged. Google Sheets uses Apps Script, so the practical choices are to record a new macro, rewrite the VBA in Apps Script, or try Google’s Macro Converter where it is available, then test the result against the original workbook.
Why Excel macros do not transfer directly
Excel macros are commonly written in Visual Basic for Applications (VBA) and use Excel’s object model: code refers to workbooks, worksheets, ranges, charts, and other Excel-specific objects. Google Sheets automation uses Apps Script, a JavaScript-based environment with its own services and object model. The languages and the spreadsheet applications they control are different, so changing a file extension or uploading a workbook does not translate the macro.
You can upload an .xlsm workbook to Google Drive and open or convert spreadsheet data in Sheets, but its VBA macros do not become working Google Sheets macros. In particular, an Excel file opened in Office-editing mode is still an Excel-format file; that does not make its VBA executable in the browser-based Sheets environment. To create a native Sheets file, use File > Save as Google Sheets when that option is available. Keep the original .xlsm file, because conversion and import can affect features that Sheets does not support.
This distinction matters even when a macro looks simple. A VBA procedure that copies a range may be straightforward to recreate, while one that controls desktop windows, reads local files, communicates with other Office applications, or depends on Excel add-ins may need a different design. The first task is therefore to identify what the macro actually does, not merely to copy its code.
Assess the workbook before converting it
Make a working copy of the Excel file and inventory the automation before changing the original. Check the VBA project for every macro, note how users start each one, and record its inputs, outputs, and assumptions. A button, a keyboard shortcut, a workbook-opening event, and a scheduled process are different ways of triggering code; a replacement must preserve the relevant behavior, not just the visible actions.
- List each macro and describe its purpose in plain language, such as importing a monthly file, cleaning rows, or preparing a report.
- Record the sheets, named ranges, tables, formulas, charts, and external files it reads or changes.
- Identify dependencies such as Outlook, other Office applications, add-ins, network drives, or Windows-only paths.
- Note error handling, password protection, user prompts, and any assumptions about the active sheet or selected cell.
- Check whether the workbook contains features that may change during conversion, including data connections, pivot tables, controls, or specialized formatting.
This inventory helps separate the business rule from its Excel implementation. For example, “copy completed orders to an archive sheet” is a rule that can often be reproduced in Sheets. “Use a Windows file picker to open a local file and control an Outlook message” depends on desktop applications and will not transfer as the same operation.
Choose a conversion method
For a small, predictable task, recording a new macro is often the quickest route. In Google Sheets in a web browser, open the converted spreadsheet and choose Extensions > Macros > Record macro. Perform the supported actions, stop recording, and save the macro. Sheets creates Apps Script code for those recorded steps. This works best for repeatable formatting or straightforward range operations; a recording does not infer the intent of a complex VBA procedure.
For an existing VBA project, Google’s Macro Converter may help where the feature is available. It can analyze supported VBA patterns and produce Apps Script code or a compatibility report, but it is not a promise that every macro will convert or behave identically. Availability can depend on the organization’s Google Workspace edition and administrator settings, so check current Google Workspace documentation or ask the administrator before planning around it. Treat its output as a starting point that requires review and testing.
Manual rewriting is the most flexible method when the macro contains business logic, unsupported Excel features, or external integrations. In the Sheets browser, Extensions > Apps Script opens the script editor for the spreadsheet. The rewrite uses Apps Script services, such as SpreadsheetApp for spreadsheet operations, rather than VBA’s Excel objects. A hybrid approach is also reasonable: use a converter for the easy sections, then replace unsupported or awkward pieces by hand.
- Record a new macro when the task is short and consists mainly of actions available in Sheets.
- Try a converter when there is a substantial VBA project and the relevant Workspace account supports it.
- Rewrite manually when reliability, custom logic, integrations, or long-term maintainability matters most.
- Keep the process in Excel if it relies on desktop-only features that Sheets cannot reproduce economically.
How a manual rewrite works
Start by expressing the macro as a sequence of requirements: what data it reads, what conditions it checks, what it changes, and what it should do when something is missing. Then map each requirement to a Sheets or Apps Script capability. A VBA loop over Excel cells may become a JavaScript loop over values read from a Sheets range. Often it is better to read a whole range into an array, process the values in the script, and write results back in batches rather than issue a spreadsheet request for every cell.
For example, suppose a VBA macro scans a sales sheet, selects rows marked Complete, and copies them to an archive. The rewrite needs to decide what identifies a row, whether existing archive entries should be skipped, how headers are handled, and whether the source rows remain in place. Those decisions are part of the workflow, not details a translator can safely guess. Once the logic is specified, implement the equivalent using Apps Script’s spreadsheet services and test it on a copy containing representative data.
Do not assume that matching function names imply matching behavior. Excel and Sheets differ in their object models, supported features, date handling, formula behavior, and available integrations. VBA can call Windows APIs or automate desktop Office programs; Apps Script runs on Google’s servers and cannot simply control a user’s local computer. If the macro needs an external system, investigate whether that system offers an approved web API and whether Apps Script can access it under your organization’s security policies.
Important differences in triggers and user access
Excel macros may run from a button, a workbook event, or a user’s desktop session. In Sheets, users can run macros from Extensions > Macros after the script has been set up, and Apps Script can also use triggers for supported events or schedules. A recorded macro can be associated with a menu entry, but the interaction will not necessarily look like the Excel button or dialog. Recreate the trigger and user experience deliberately, rather than assuming it will carry over.
Apps Script may request authorization when a script accesses spreadsheet data or other services. A simple script restricted to its spreadsheet has different implications from one that accesses email, Drive files, or an external service. Some triggers also have restrictions, and installable triggers run under the account that created them. For a shared workflow, establish who owns the script and trigger, what happens if that person leaves, and which users need permission to run it.
Sheets is designed for browser-based collaboration, while an Excel VBA macro commonly runs in a desktop Excel session. A converted process may therefore be easier for a distributed team to access, but that does not make every desktop workflow a good fit. Consider simultaneous edits, protected ranges, user roles, and whether a script could overwrite changes made by another person.
Test behavior, not just whether the script runs
A script that completes without an error can still produce the wrong spreadsheet. Compare the output of the original macro and the new process using a copy of the same input data. Include ordinary cases and awkward ones: blank rows, duplicate records, unexpected dates, missing values, unusually large data sets, and a second run on data already processed. Check formulas, formatting, totals, and side effects, not only the rows that were moved.
- Run the original process on a safe copy and save its output as a reference.
- Run the Sheets version on equivalent input and compare important cells and records.
- Test cancellations, missing files, invalid entries, and other expected error conditions.
- Confirm the trigger works for the intended users and that authorization prompts are understood.
- Document how to recover, who maintains the script, and how changes will be tested later.
Pay particular attention to repeatability. If a macro appends rows, a second run might create duplicates unless the script checks what is already in the archive. If it clears a range before writing, verify that the range cannot include notes or formulas that users need. These are common reasons a technically successful conversion can still disrupt a real process.
Security, maintenance, and practical costs
Review converted or rewritten code before authorizing it. A script should request only the access it needs, and users should understand which account owns it and what data it can reach. Avoid copying code from an unknown source into a shared spreadsheet without review. Organizations should also follow their Workspace administrator’s rules for Apps Script, external connections, and data sharing.
There may be no separate charge for a small rewrite using tools already included in an account, but availability of conversion tools, administrator controls, Workspace licensing, and developer time can affect the real cost. A complex VBA application may require substantial redesign, testing, and ongoing support; a short recorded formatting macro may take much less effort. If the process is business-critical, estimate maintenance as well as initial conversion, and verify current product and licensing details with Google or the organization’s administrator.
For some workflows, keeping Excel is the sensible alternative. Continue using Excel when the macro depends on desktop automation, unsupported controls, specialized add-ins, or a large VBA codebase that would be costly to replace. Another option is to move only the shared data or reporting layer to Sheets while retaining the Excel process, provided that the handoff is secure and does not create conflicting copies.
Frequently Asked Questions
Can Google Sheets run VBA macros?
No. Google Sheets does not execute Excel VBA. A macro must be recreated in Apps Script or replaced by another workflow that works in Sheets.
Will my macros come across when I convert an XLSM file?
Do not expect them to. Spreadsheet data and some workbook features may transfer, but VBA code does not become a working Sheets macro through file conversion. Keep the original workbook and verify the converted file’s contents.
Can I convert Excel VBA to Apps Script automatically?
Google’s Macro Converter can assist with supported VBA projects where it is available, but conversion may be incomplete. Review the generated code, resolve unsupported items, and test the result using representative data.
How do I make a Google Sheets macro?
In Sheets in a browser, choose Extensions > Macros > Record macro, perform the supported actions, and save the recording. For custom logic, open Extensions > Apps Script and write or revise Apps Script code.
Should I convert every Excel macro?
No. Convert only the workflows that benefit from being in Sheets and can be reproduced reliably. If a macro depends on desktop Excel, local files, or other Office programs, retaining it in Excel or redesigning the wider process may be more practical.
Related
- Excel Time Zones: How Date and Time Conversion Works
- Excel Text Across Cells Without Merging
- Excel Time Shortcut: How to Insert the Current Time
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Access VBA Date Conversion: Parse, Format, and ValidateIn Access VBA, use CDate to convert a value VBA already recognizes as a date, DateSerial to build…
- Excel VBA Documentation: Where to Find the Right HelpExcel VBA documentation is available from Microsoft Learn: use the Excel object model reference for Excel-specific objects and…
- Import CSV to Excel Using VBA: A Safe, Repeatable MethodTo import a CSV file into Excel with VBA, use Workbooks.OpenText to parse the file, then copy its…
- VBA Array Add: How to Append Values and Resize an ArrayVBA has no built-in Array.Add method. To add values, use a dynamic array and resize it with ReDim…
- Excel VBA Get Username: Windows or Excel User Name?In Excel VBA on Windows, use Environ$("USERNAME") to read the current Windows account name. Use Application.UserName instead if…
- VBA Loop Through a Range: Examples and Best PracticesTo loop through cells in Excel VBA, use For Each cell In worksheet.Range("A1:A10").Cells and place the action you…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.