Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8708879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:14:17+00:00 2026-06-13T04:14:17+00:00

This seems like it should be easy as pie, but I can’t seem to

  • 0

This seems like it should be easy as pie, but I can’t seem to get any of my little test implementations to work. The ultimate goal is to create a function that runs only when cells in a certain range are edited. To accomplish this, I am creating a function that runs on every edit but starts by checking to see if the range of the edited cell is within a certain range, and only executing the rest of the code if this is true, and otherwise, it just ends immediately.

The first step in doing this, it seems to me, is to find out how to return the range of the edited cell. I’ve tried various tests.

Here is the current version, which I test by editing the spreadsheet:

function onEdit(e){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var eRange = e.range;
var message = eRange.getA1Notation();
ss.toast(message);
}

(output: toast does not appear/nothing happens)

I had about 10 other versions posted here, but I realized it was not helpful.

I’ve managed to return [object Object] and [undefined] in my toast message, so I know I’m not making some silly error with my toast function.

Doesn’t e.range return a range? Is that where I go wrong? If it returns a range, shouldn’t I be able to use any of the methods in range, just as if I’d used something like “ss.getRange(“A1″).someMethod()”? Or is there some difference that I don’t understand?

Okay, I realize I’ve asked a couple of different questions here– I’m just trying to give a clearer picture of my thought process in case it helps you to correct me where I’m wrong. The simple question is this: what sort of command or method can I use to return the range of an edited cell?

I’m so sorry to ask such a basic question. I’m really afraid that someone will enter the right combination of search terms and the answer will be right on the top of the results… but I just can’t seem to find it on my own, so here I am. I’ve tried lots of snippets of code from both StackOverflow and the old Google Groups support forum, as well as lots of my own attempts. I see people have asked lots of similar questions regarding my ultimate goal here– only running the onEdit function if cells in a certain range are edited– but the answers are all more complex and seem tailored to each individual situation, and they don’t fit mine. I’m certain the answer is out there, but I’ve been searching for three straight evenings now and found many similar questions asked, and just can’t seem to get my own implementation of those suggestions to work. Thanks for being patient with me, and thank you so much for any answers you can offer!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:14:18+00:00Added an answer on June 13, 2026 at 4:14 am

    here is the code taken (and slightly modified) from the doc :

    function onEdit(event){
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var sh = event.source.getActiveSheet();
      var r = event.source.getActiveRange();
      r.setComment("Last modified: " + (new Date())+' by '+Session.getActiveUser());
      ss.toast('Last cell modified = '+r.getA1Notation()+' by '+Session.getActiveUser());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seems like this should be the easy part, but I can't seem to get
This seems like it should be easy, but I can't get it to work
This seems like it should be prettty easy - but I just can't get
This seems like it should be easy, but I can't get the right syntax.
This seems like it should be easy, but I can't quite find an explanation
This seems like it should have a super easy solution, but I just can't
So this seems like it should be easy, but I can't quite figure out
This seems like it should be an easy one but I can't figure it
This seems like such an easy problem, but I can't seem to find a
This seems like it should be super easy, but I can't figure it out.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.