Address common issues

  • When converting VBA to Apps Script with the Macro Converter, printing behavior might differ, with APIs converting to file output instead of direct printer output.

  • Features like certain triggers, Userforms, and some types of Named ranges are not automatically converted and require manual conversion or workarounds.

  • Manual steps are provided to recreate Userform dialogues in Apps Script and address unsupported named ranges like Tables.

Common issues you might run into when you convert your VBA code to Apps Scriptwith the Macro Converter are listed below.

Printing

VBA APIs that print files are automatically converted to Apps Script, but mightbehave differently than the original VBA API. Below are two examples:

VBA APIBehavior in Apps Script
PrintOutConverts to Apps Script, but the Apps Script API prints to a file instead of a printer. You can manually print the PDF file.
PrintToFileConverts to Apps Script. The PDF file is saved in your MyDrive folder.

Unconverted items

The following features aren’t converted by the Macro Converter and need to beconverted manually:

Triggers

Two types of triggers, keyboard shortcuts and some event-based triggers, aren’tconverted by the Macro Converter. In many cases, you can create these triggersmanually.

Keyboard shortcuts

To add keyboard shortcuts, follow the steps toimport functions asmacros.

Event-based triggers

Some events from VBA code, likeBeforeClose orBeforeSave, don’t haveequivalents in Apps Script, but you might be able to create a workaround.

For events likeBeforeClose, you can create a custom menu or button to clickto perform the action that needs to take place before you close the spreadsheet.

Since Google Sheets auto-saves each edit, workarounds for events likeBeforeSave aren’t feasible.

Userforms

In VBA, aUserForm is a window or dialog box in an application's userinterface (UI). The Macro Converter doesn’t convert UserForms. You can manuallycreate them in Apps Script.

Create a user form dialogue

  1. On your computer, open the converted file inGoogle Sheets.
  2. At the top, clickExtensions>** Apps Script**.
  3. At the left of the editor next to "Files," click Add a file> HTML. We recommend that you give the HTML file the same name as youroriginal VBA UserForm.
  4. Add the fields and information you want to appear in your form. Learn moreabout HTML forms atW3school.com.
  5. At the left, click the Apps Script file (GS file) that has your convertedcode.
  6. If you already have anonOpen() trigger in your code, update it with thecode below. If you don’t have theonOpen() trigger in your code, addthe code below.
    functiononOpen(){SpreadsheetApp.getUi().createMenu('User Form').addItem('Show Form','showForm').addToUi();}functionshowForm(){varhtml=HtmlService.createHtmlOutputFromFile('userform_module_name').setWidth(100).setTitle('Sign-up for Email Updates');SpreadsheetApp.getUi().showSidebar(html);}
  7. Replaceuserform_module_name with the name of the HTML file you added.
  8. At the top, click Save project.
  9. Switch to the Google Sheet and reload the page.
  10. At the top of the Google Sheet, clickUser Form >Show Form.

Named ranges

In Excel, named ranges are names given to a single cell or range of cells.

When you convert your Excel file to Google Sheets, some types of named rangeswon’t be converted because they’re not supported. Below are two examples:

Unsupported named rangesDescription
TablesNot supported in Google Sheets, but has a workaround.

To recreate this named range in Sheets, add a named range that points to the A1 notation of the table range. Use the same name as the original named range in your VBA code so that the converted code recognizes it.
List of rangesNot supported in Google Sheets. There isn’t a workaround.

Related articles

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.