Changing background color of specific cell on Google sheet

You can use setBackground property with getRange. Try the below snippet. function myColorFunction() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var range = ss.getSheetByName(“Form Responses 1”).getRange(2,6,ss.getLastRow()); var cellRange = range.getValues(); for(i = 0; i<cellRange.length-1; i++){ if(cellRange[i][0] == “Open”) { ss.getSheetByName(“Form Responses 1”).getRange(i+2,6).setBackground(“red”); ss.getSheetByName(“Form Responses 1”).getRange(i+2,6).setFontColor(‘white’); } } }

How to enable autocomplete for Google Apps Script in locally-installed IDE

I found the solution that partially works, but it may not be applicable to other software. The steps below are for Visual Studio Code: Install the NPM package containing type definitions for GAS using https://www.npmjs.com/package/@types/google-apps-script In your locally-saved script, create a ‘.js’ file and type import ‘google-apps-script’;

Trying to read cell 1,1 in spreadsheet using Google Script API

You have to first obtain the Range object. Also, getCell() will not return the value of the cell but instead will return a Range object of the cell. So, use something on the lines of function email() { // Opens SS by its ID var ss = SpreadsheetApp.openById(“0AgJjDgtUl5KddE5rR01NSFcxYTRnUHBCQ0stTXNMenc”); // Get the name of this SS … Read more

How to convert Time into decimal float in Google Sheets using Script?

Google Sheets In Google Sheets, if you have a date/time value in a cell (e.g. “D9”), then use =HOUR(D9)+(MINUTE(D9)/60). If the value is stored in the format 04:29, then use =INDEX(SPLIT(D9, “:”), 1) + (INDEX(SPLIT(D9, “:”), 2)/60). Google Sheets API & Google Apps Script If you want to use the Google Sheets API or Google … Read more

“We’re sorry, a server error occurred. Please wait a bit and try again” error when running a function from a custom menu

Problem Solved. The problem is with string replace function in some other function. I am using the string replace function with regular expression as input to replace function. The regular expression was incorrect due which i am getting the above error. That’s really weird, at least GAS should give some proper error.

How do I use momentsjs in Google Apps Script?

Most people try to use the library with the key ending in 48. That library is pretty dated (it is version 2.9 which is pretty old). Using eval and UrlFetchApp.fetch moment.js or any other external library can be used easily in google app scripts. function testMoment() { eval(UrlFetchApp.fetch(‘https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js’).getContentText()); var date = moment().format(“MMM Do YY”); Logger.log(date) … Read more

Custom function throws a “You do not have the permission required to setValue” error

from the documentation : Custom functions return values, but they cannot set values outside the cells they are in. In most circumstances, a custom function in cell A1 cannot modify cell A5. However, if a custom function returns a double array, the results overflow the cell containing the function and fill the cells below and … Read more