GAS on Android mobile - switching active sheet?

102 views
Skip to first unread message

rob wilson

unread,
Oct 9, 2023, 3:30:30 PM10/9/23
to Google Apps Script Community
I am building a Google spreadsheet, with multiple sheets, which would be great to have on a mobile platform. The main sheets are a jobs database, a summary sheet, and add (new job) and edit sheets.

So far I have been able to overcome button challenges, by using checkboxes.
But now the problem I'm facing is how to switch the active sheet to sheetname. This code works on desktop only:

let ss = SpreadsheetApp.getActiveSpreadsheet()
let sh = ss.setActiveSheet(ss.getSheetByName(sheetname))

I've seen solutions using: 
sh.getRange('A1').activate()
but it doesn't work for me:

Does anyone know of a solution?

I guess I could simply rebuild the active (viewed) sheet from templates.

Keith Andersen

unread,
Oct 9, 2023, 4:04:10 PM10/9/23
to google-apps-sc...@googlegroups.com
Are you trying to have your scripts run on a mobile phone similar to pressing a button?

If so is this kind of what you're looking for

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/8d2e5772-4f5b-4c2a-83c1-2f5016e0f6c2n%40googlegroups.com.

Keith Andersen

unread,
Oct 9, 2023, 4:16:23 PM10/9/23
to google-apps-sc...@googlegroups.com
let sh = ss.setActiveSheet(ss.getSheetByName(sheetname))

sheetname needs to be in quotes like;
let sh = ss.setActiveSheet(ss.getSheetByName("sheetname"))

rob wilson

unread,
Oct 13, 2023, 11:58:57 PM10/13/23
to Google Apps Script Community
I'm puzzled - I did reply (via Gmail) to Keith on 9th Oct, but I don't see the reply in this forum. Am I missing something?
Keith, this is what I wrote:
"Hi Keith, yes indeed. I've been using checkboxes, bit I like the drop down approach in that article too. Many thanks"

I have since worked on using your approach and it's going pretty well!
Thanks again, Rob

Keith Andersen

unread,
Oct 14, 2023, 12:24:18 AM10/14/23
to google-apps-sc...@googlegroups.com
Sorry Rob, it must have gone into my spam folder I have had that happen on many occasions. 

Glad it worked out for you 👍



Reply all
Reply to author
Forward
0 new messages