20 votes
Accepted

Diference between onEdit or onChange trigger?

based on a quick search these are the differences between onEdit(e) and onChange(e): onEdit(e): brief description: The onEdit(e) trigger runs automatically when a user changes the value of any ...
  • 24.9k
5 votes

How to make Google Sheet jump to today's column when opened?

try this code: function onOpen() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getActiveSheet(); var range = sheet.getRange("2:2"); var values = range.getValues(); values = ...
4 votes

How to make Google Sheets jump to today's row when opened?

If you are open to use filters and to hide the other rows, use a filter / filter view with Filter by condition set to Date is > Today Comparison to other alternatives This will work for editors and ...
  • 42.4k
4 votes

How to make Google Sheet jump to today's column when opened?

If your dates are in column A, and you want your file to be opened on today's row: In your google sheet: add this in the cell A1: =match(TODAY();A2:A;0)+1 It will return the row number which ...
  • 441
4 votes

Script to copy values only

Your last line has a mislaid close-paren. Rather than: sheet.getRange(range.getRow(), 1, 1, sheet.getLastColumn()).copyTo(targetRange), {contentsOnly:true}; the copyTo "options"-object parameter ...
  • 630
3 votes

Google Sheets Script Editor action not applying to all sheets

Get the sheet that was edited. Change code to: var sheet, ss; ss = SpreadsheetApp.getActiveSpreadsheet(); sheet = ss.getActiveSheet();//Get the active sheet Now the sheet variable is the active ...
3 votes

How do you create an installable trigger for a Google Apps Script?

Short answer It's not possible to populate a Google Form ListItem based on the user using the form as respondent. Explanation Google Forms has two main views: Editor view: Available to the form ...
  • 42.4k
3 votes

How to make Google Sheets jump to today's row when opened?

It's much simpler now in 2017 :) Simply add "&range=A6" after the URL of the Google Sheet. The "&range" is the range that you want the cursor to be at, and the "A" is for the column, and the ...
3 votes

onOpen doesn't execute

Solution was to go to Resources -> Current Triggers and add a new trigger in the Script project.
  • 159
3 votes

onEdit only updates top row after pasting (editing) multiple rows

onEdit can be written to take an event parameter that among other things contains the range that was edited. Changing the function declaration to take a parameter 'event' and changing r to be event....
3 votes
Accepted

How can I have onEdit trigger when specific cells are selected?

Add getValue() to var r = sheet.getRange("D11");. The resulting code line is: var r = sheet.getRange("D11").getValue(); The above because getRange returns Range object which not return directly it'...
  • 42.4k
3 votes
Accepted

TypeError: Cannot read property 'range' of undefined at onformsubmit again after creating an event object

How to Fix your problem Manually install the onFormSubmit trigger. When installing the Trigger, under "Choose which function to run", choose the function onFormSubmit (the trigger event argument () ...
  • 4,868
2 votes

Can I add an autoincrement field to a Google Spreadsheet based on a Google Form?

This is a derivative of the other answers but it might be useful for future users. function onEdit(e) { var sheet = SpreadsheetApp.getActiveSheet(); var row = SpreadsheetApp.getActiveSheet()....
  • 121
2 votes

Creating multiple timestamps on Google Sheets to make dependent drop-down boxes work

Having two onEdit scripts isn't gonna work. So try to merge the two scripts into one... function onEdit(e) { var s = e.source.getActiveSheet(), sheets = ['In', 'Out'], ind = sheets.indexOf(s....
  • 2,439
2 votes

How to make Google Sheets jump to today's row when opened?

Loop through all days column and then: if (day == new Date()) { //then get cell sheet.setCurrentCell(cell); } using this method
  • 21
2 votes
Accepted

Is there any way to identify a user in Google Apps Script?

I searched for this earlier and figured out that it depends if you have private accounts or part of the same company. For private accounts it's not possible, at least it was not when I researched. My ...
  • 198
2 votes
Accepted

Can I limit how frequently an 'on open' script runs?

Say I'm forgetful, but I don't want to pester my coworker by calling her more than every two hours. I might remind myself just by jotting down when I call, so I can glance at that note next time I'm ...
  • 630
2 votes

Trying to run two scripts on same sheet and getting error

You're missing the text "function" in front of oneditfx1 and oneditfx1. Also, your huge if/else if statement could be simplified by using a switch statement and nesting furthers ifs within that.
2 votes
Accepted

Determining location of checkbox that activated a script?

Use on edit / on change triggers and the corresponding event object. Example function onEdit(e){ var a1Notation = e.range.getA1Notation(); e.source.toast(a1Notation + ' was clicked'); } Related ...
  • 42.4k
2 votes

Prevent a Google Script from Modifying Date

Whenever any text is entered in a cell, you want to convert it to uppercase. But your script applies to all kinds of types (includes dates and numbers) and this has undesirable results. Javascript ...
  • 4,868
2 votes

Hide/Unhide rows based on values in particular cells

When you have two onEdit(e) functions in the same script project, only one of them will run. The simplest pattern to combine two onEdit(e) functions is to rename the existing functions to ...
  • 7,343
2 votes
Accepted

Google Sheets: On change, delete a specific row if a certain cell is blank

and there you have it: function myFunction() { var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("preEnrollment"); var sheet2 = SpreadsheetApp.getActiveSpreadsheet()....
  • 63
1 vote

How do I lock a sheet in Google Sheets at a specific time every day?

I believe, You're looking for something like time-driven trigger So, there are at least two options for Your case: Manual setup, which does not seam very versatile, but You can setup a call of ...
  • 136
1 vote

The script does not have permission to get the active user's identity

The range the script tried to add notes was within a protected range. That's why it works for app owner but not shared editors. I just unprotected the range for the script and it worked. Not ideal but ...
  • 159

Only top scored, non community-wiki answers of a minimum length are eligible