I'm looking to write a function for Google Sheets Script that accepts a cell reference and outputs the date that cell was last modified. I'm not sure how to get started.
How do I create a function that returns the last time a cell was modified?
1.1k Views Asked by Tarrasque_in_a_hole At
1
There are 1 best solutions below
Related Questions in GOOGLE-APPS-SCRIPT
- How to use custom font during html to pdf conversion?
- parameter values only being sent to certain columns in google sheet?
- AppScript to replace image in google slides
- Email Sent Using AppScript Appears in Sent Box, but does not appear in Recipient's Inbox
- Update a MySQL row depending on the ID in Google Sheets Apps Script
- Would like the script to return the PDF letter via email with the sheet name not the spreadsheet name
- App script to prevent duplicate form submission
- Redirect Users to another website using GAS
- How do I create a Line Graph on App Script?
- Error (Status of 500) and X-Frame-Options with google apps script redirect function
- How do I add the Luxon library google sheet script
- AppScript For Google Form
- google sheet script to convert the Scientific notation in the selected area to number
- onEdit() 'row is not defined' error using checkboxes
- Regex expression not working on Google Form
Related Questions in GOOGLE-SHEETS-CUSTOM-FUNCTION
- Custom Function Google Sheets that displays a message containing a value from another cell
- Creating a pop-up form on google sheets using custom forms
- Custom function with variable arguments implementation using apps script
- Calculating with time
- Custom Sheets function to be used with ARRAYFORMULA
- -Custom function return does not update
- Google Spreadsheet Custom Functions when evaluated/executed?
- How to get auto refresh google spread sheet custom cell fuction from google app script [ custom fuction refresh ]
- Parallelizing requests with fetchAll in a custom function causes it to crash
- How do I create a function that returns the last time a cell was modified?
- SpreadsheetApp.openById displays error when run via the onOpen command
- Why isn't array Intersection in google spreadsheet working as expected?
- Make a simple counter in Google Scripts which keeps track of previous value
- Search through all sheets for a string which have a specific value in the cell next to it
- How to add a table of contents to a Google Sheets spreadsheet?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
There's no direct approach to get the exact date of a cell's edit.
Method 1
Retrieve the
modifiedTimeusing the Drive API'sFiles:getwhich will return, according to the documentation:Method 2
What you can do instead is to make use of the
onEdit(e)trigger and monitor each change from the particular cell.So for example, considering that the cell you want to check is
A1, you can use this snippet:Snippet
Explanation
The above function is an
onEdittrigger which will fire every time there's an edit made on the sheet. Since you want to check this for a particular cell, the event objectehas been used in order to get therowand thecolumnof the cell which has been edited. Therefore, theifcondition in this situation checks if therowis equal to1and the column is equal to1(range corresponding to theA1cell) and based on that, it returns the current date which corresponds in this situation to the edit that has been made.To track all the edits for a cell, you can store the
datevariables resulted from the edit to an array and eventually use it afterwards to your liking.Note
Taking these into account, you won't be able to get the time of a cell which has been edited before having the trigger into place.
Reference
Drive API v3 Files:get;
Drive API v3 Files Resource;
Apps Script Event Objects;
Apps Script Simple Triggers.