samedi 21 décembre 2019

How do I avoid conflicting code and how do I fix it [closed]

So, right now the

    sheet.showRows(9)
    sheet.showRows(10)
  } else {
    sheet.hideRows(9)
    sheet.hideRows(10)

is not working. It recognizes the if class = warlock but not the level >= 2. It shows it if those conditions are met and if not they never show. Here is the full code.

function onEdit() {
var sheet = SpreadsheetApp.getActive().getSheetByName('Class');
var level = sheet.getRange('K3').getValue();
var class = sheet.getRange('Traits!L3').getValue();
  if (class == "Warlock" && level >= 2) {
    sheet.showRows(9)
    sheet.showRows(10)
  } else {
    sheet.hideRows(9)
    sheet.hideRows(10)
  if (level >= 2) {
    sheet.showRows(7);
    sheet.showRows(8);
  } else {
    sheet.hideRows(7);
    sheet.hideRows(8);
  }
  if (level >= 3) {
    sheet.showRows(12);
    sheet.showRows(13);
  } else {
    sheet.hideRows(12);
    sheet.hideRows(13);
  }
  }
}

Is there anything wrong with the if statement that can be fixed.

Aucun commentaire:

Enregistrer un commentaire