Reputation: 11
I cannot get this if/else to replace more than one row of of the column at a time. I have tried
spreadSheet.getRange(2, 38, 4000)
spreadSheet.getRange(2, 38, spreadSheet.getLastRow()-1)
and
spreadSheet.getRange(2, 38, sheet.getMaxRows())
It's not returning anything if it's not set up like below (and that only returns one cell.
function calculateHitPoints(){
var spreadSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Form Responses 1");
var setHP = spreadSheet.getRange(2, 38).getValues();
if(setHP == "Fighter"){
spreadSheet.getRange(2, 38).setValue("14");
}
else if(setHP == "Ranger"){
spreadSheet.getRange(2, 38).setValue("13");
}
}
Upvotes: 1
Views: 61
Reputation: 33
It's because you're getting row 2 in column 38. That's why it's only getting that cell only.
getRange() has multiple implementations you can refer to this links here.
Sheet.getRange(row, column, numRows)
Sheet.getRange(row, column, numRows, numColumns)
Upvotes: 1