Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDaniel Turner
6,738 PointsI'm having trouble with this for loop. can someone help?
function linkTotals() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; var newSheet = ss.getSheets()[2]; var name = newSheet.getSheetName();
/var oldS = sheet.getRange("D4:E5"); var newS = "'" + name + "'!C3"; var finalS = oldS.getFormula() + " + " + newS; oldS.setFormula(finalS);/
var oldS = sheet.getRange("D4:D5"); var lc = oldS.getLastColumn(); var lr = oldS.getLastRow();
for(var i=0; i<lc; i++)
{
for(var j=0; j<lr; j++)
{
var newS = "'" + name + "'!D4";
var finalS = oldS.getFormula() + " + " + newS;
oldS.setFormula(finalS);
}
}
}