So
function onEdit() {
var sheet = SpreadsheetApp.getActive().getSheetByName('Class');
var level = sheet.getRange('K3').getValue();
var class = sheet.getRange('Traits!L3').getValue();
if (class == "Warlock") {
if (level <= 2) {
sheet.showRows(9)
sheet.showRows(10)
}
}
if (level == 1) {
sheet.hideRows(7);
sheet.hideRows(8);
} else {
sheet.showRows(7);
sheet.showRows(8);
}
if (level <= 2) {
sheet.hideRows(12);
sheet.hideRows(13);
} else {
sheet.showRows(12);
sheet.showRows(13);
}
if (class=="Warlock") {
sheet.getRange('A7:D7').breakApart();
sheet.getRange('A7:D7').mergeAcross();
} else if (class=="Fighter") {
sheet.getRange('A7:D7').breakApart();
sheet.getRange('A7:B7').mergeAcross();
}
}
This code is supposed to show rows 9 and 10 when your class is warlock, however, it isn't doing that. What the code does is figure out if you are a fighter or a warlock, then breaks and merges cells to look fancy and for visual purposes, then figures out your level the hides and shows rows based on that. Why? because fighters do different things than warlocks do and there class feature are complete antithesis of each other therefore I have to make a visually appealing sheet.
Now is there something wrong that I'm not seeing or is the code itself wrong?
Aucun commentaire:
Enregistrer un commentaire