0

I'm completely new to programming and I'm trying to write this ridiculous easy script but it just won't work.. Anyone who can help me out?

I think the script makes clear what I want to do but let met provide a short explanation: If cell1, cell2 and/or cell 3 is empty I want a red line to appear and if there's something within the cell I want a blue line to appear.

Right now the script only generates a blue line and then nothing.

function CreateBorder() {

  var app = SpreadsheetApp;
  var ss = app.getActiveSpreadsheet();
  var activeSheet =ss.getSheetByName("flyer");
  var cell1 = activeSheet.getRange("B12");
  var cell2 = activeSheet.getRange("B15");
  var cell3 = activeSheet.getRange("B18");

  if (cell1.getValue !== "") { 
    cell1.setBorder(null, null, true, null, false, false, "blue", null);
  }
  else {

    cell1.setBorder(null, null, true, null, false, false, "red", null);
  }


  if (cell2.getValue !== "") { 
    cell2.setBorder(null, null, true, null, false, false, "blue", null);
  }
  else {
    cell2.setBorder(null, null, true, null, false, false, "red", null);
  }


  if (cell3.getValue !== "") { 
    cell3.setBorder(null, null, true, null, false, false, "blue", null);
  }
  else {
    cell3.setBorder(null, null, true, null, false, false, "red", null);
  }
}
0

getValue is a function definition in the range object. It'll never be empty. Invoke your function by using () like getValue().

Logger.log("getValue is a"+ cell1.getValue)
Logger.log("result of executing  function getValue is"+ cell1.getValue())

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.