I am looking to remove borders in cells AG64:BE68 on the below spreadsheet based on whether Cell AG64 is blank or populated. I am aware its not possible to do just using conditonal formatting but believe it is possible to do using google script. I have had a look at some other posts but have been struggling to understand how to change the formatting to just these cells and not the whole sheet. If somebody could advise that would be great


  • Welcome to Web Applications Stack Exchange. The link gives "You need access." Nov 16, 2022 at 15:06
  • Should be able to view now Nov 16, 2022 at 15:12
  • Hi, welcome to WebApps. For your future reference, the details of your question should stand on their own, and shouldn't require volunteers to open your spreadsheet to obtain more information. In addition, your spreadsheet is in "View" mode, so the formulas adjacent to column AG aren't naturally visible; you should describe these in your question.
    – Tedinoz
    Nov 17, 2022 at 23:01
  • As the asker, you have a special privilege: you may accept the answer that you believe is the best solution to your problem.
    – Tedinoz
    Nov 20, 2022 at 1:17

1 Answer 1


Use an onEdit(e) simple trigger and Range.setBorder(), like this:

* Simple trigger that runs each time the user hand edits the spreadsheet.
* @param {Object} e The onEdit() event object.
function onEdit(e) {
  if (!e) {
    throw new Error(
      'Please do not run the onEdit(e) function in the script editor window. '
      + 'It runs automatically when you hand edit the spreadsheet.'

* Draws borders around a range of cells when a cell in a magic column
* is edited and the new value in the cell is the word HEAT.
* Removes borders when a cell is cleared and the old value in the cell
* was the word HEAT.
* @param {Object} e The onEdit() event object.
function borderizeWildly_(e) {
  // version 1.0, written by --Hyde, 16 November 2022
  //  - see https://webapps.stackexchange.com/q/167769/269219
  if (![e.value, e.oldValue].includes('HEAT')
    || ![2, 33].includes(e.range.columnStart)) {
  e.range.offset(0, 0, 5, 25)
    .setBorder(...new Array(6).fill(e.value === 'HEAT'));

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.