0

I'm trying to make a useful schedule sheet to keep track of all of my class assignments:

I want to write a script in the script editor that says,

for(Column A-Z){
    if(A2,B2,etc = TODAY()){
        Set the border of column A, B, etc to be a green outline
    }else{
        Set an empty border
    }
}

So that it looks like this:

So it needs to automatically outline the column that represents the current day. But I don't really get how to use the Google Sheets API, so I'm at a loss for how to actually make this code work.

0

Google Sheets built-in functions are not support on Google Apps Script.

Instead of TODAY() built-in function we could use JavaScript to get the same result as that function.

Below is a function that returns the same result as TODAY built-in function:

/**
 * Returns a date object with the time set to 12:00:00 AM which is the same
 * as Google Sheets TODA() built-in function.
 */
function today(){
  return new Date().setHours(0,0,0,0);
}

Then to set the border use

  • setBorder(top, left, bottom, right, vertical, horizontal)
  • setBorder(top, left, bottom, right, vertical, horizontal, color, style)

For details, including code examples, please checkout https://developers.google.com/apps-script/reference/spreadsheet/range

Related

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.