Check if 1 notation is correct/valid

171 views
Skip to first unread message

Gurnoor Rana

unread,
Mar 4, 2023, 11:27:58 AM3/4/23
to Google Apps Script Community
Hi,
Using Apps Script, I am trying to take user's input for a cell position as A1 notation and then edit a value there.
Before doing that, I want to check if what they typed is valid a1 notation text or not. I know it might likely be a regex check but I don't know about it that much.
Thanks for the help.

cwl...@gmail.com

unread,
Mar 4, 2023, 12:59:02 PM3/4/23
to Google Apps Script Community
I would first try to see if apps script throws an error if the userinput is not a valid A1 range. Something like:

if ( !sheet.getRange(USERINPUT).getA1Notation()  ) {
  return "Please enter a valid range in the form 'A1' "

McFixit

unread,
Aug 19, 2023, 8:34:34 PM8/19/23
to Google Apps Script Community
Unfortunatly sheet.getRange throws an exception before we get to evaluating getA1Notation().
It's not a big deal since I planned on just throwing an exception myself, but it does keep me from throwing the specific exception I wanted.
Reply all
Reply to author
Forward
0 new messages