google spreadsheet - How can I set a range using the value of a cell? -
i having little trouble tweaking google script. have shown part of below , try explain trying do. below part of script:
function setup() { var ss = spreadsheetapp.getactivespreadsheet(); (i = 1; <= 1; i++) { var sheet = ss.insertsheet('final grades'); sheet.getrange("a2").setformula("=arrayformula(if(isblank(grades!a9:a96),, vlookup(grades!a9:a96, grades!a9:g96, 4, false)))");
i trying replace range in isblank , vlookup commands based on total entries. have cell, located in 'grades' sheet in cell b5 contains total number of entries. trying have script take value in b5 , add range in isblank , vlookup commands.
right range a9:a96 both isblank , vlookup, trying accomplish take value located in b5 (let's 80) new line be:
sheet.getrange("a2").setformula("=arrayformula(if(isblank(grades!a9:a89),, vlookup(grades!a9:a89, grades!a9:g89, 4, false)))");
the second part of range in isblank , vlookup has changed based upon value of b5 (in case 80.) possible? if so, how this? in advance help.
this means should compose formula string dynamically, based on value of b5. readability of code, suggest doing step step:
var endrow = sheet.getrange("b5").getvalue() + 9; var formula = "=arrayformula(if(isblank(grades!a9:a" + endrow + ",, vlookup(grades!a9:a" + endrow + ", grades!a9:g" + endrow + ", 4, false)))"; sheet.getrange("a2").setformula(formula);
as result, number 96 replaced endrow on every occasion.
Comments
Post a Comment