Activate cell working on Chrome on a Windows laptop, but not Android Google Sheets app


The following code activates the correct cell when viewing/editing a Google Sheet on a Windows laptop through Chrome.

However, the cell will NOT activate with viewing/editing the same spreadsheet on an Android device through the Google Sheets app. Does anyone know if this is intentional, or is it a bug on their part, or a problem with my code?

function setActiveCell() {
    if (sheetName.getRange('B4').getDisplayValue() == '') {
      sheetName.getRange('B4').activate();
      return;
    }
    for (var x = 5; x < 30; x++) {
      if (sheetName.getRange('B'+x.toString()).getDisplayValue() == '') {
        sheetName.getRange('B'+(x-1).toString()).activate();
        return;
      }
    }
  }

Also, alert method of opening a info box does not work on Android, but does on Windows and chrome, specifically this code:

SpreadsheetApp.getUi().alert('text')

All the rest of my code works properly in both cases.

1
Feb 20 at 2:21 AM
User AvatarJean-Louis Bontront
#android#google-sheets#google-apps-script

Accepted Answer

Google Apps Script methods related to the user interface, like SpreadsheetApp.Range.activate() don't work on Android, however, onEdit simple and installable triggers might work while they don't use UI methods.

The above was not mentioned on the official documentation for years, but it has been updated "silently", so it might be added somewhere. I say "silently" because there are no notifications or a list of changes made to the documentation.

User AvatarWicket
Feb 20 at 2:26 AM
1