I've got a Google Sheet where I'm compiling an inventory. I've noticed a bunch of mathematical errors recently, so I decided to cut down on the mental addition and build an Apps Script loop that adds two columsn and resets the first column for me. But because I'm using a getValue in basically every loop, it's a very time-intensive process.
I tried looking for ways to write to arrays, etc, but this is my first foray into Google Sheets rather than Excel.
Here's the whole function:
function Update() {
var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName('Name');
for (var x = 2; x < 905; x++) {
var range1 = sheet.getRange([x],7);
var num1 = range1.getValue();
var range2 = sheet.getRange([x],8)
var num2 = range2.getValue();
range2.setValue(num1 + num2)
range1.setValue ('0')
}
}
It's working correctly, but it's really slow and I'd appreciate any tips on how to make this more efficient.