I need help modifying the script below to only subtract the row on which the change is made, instead of subtracting all rows in the sheet when the on-change trigger executes.
var sourceSpreadsheetID = '1r4e4BNKwsmdC2Ry93Mq-N49zj3DAZVpHG21TgTe0FWY';
var sourceWorksheetName = "CONCRETE";
var docketSpreadsheet = SpreadsheetApp.openById(sourceSpreadsheetID);
var docketsheet = docketSpreadsheet.getSheetByName(sourceWorksheetName);
var maxRows = docketsheet.getMaxRows();
var loadRange = docketsheet.getRange(2, 22, maxRows);
//row, column, number of rows
var totalRange = docketsheet.getRange(2, 24, maxRows);
var soldValues = loadRange.getValues();
var totalValues = totalRange.getValues();
for (var row in soldValues) {
var soldCellData = soldValues[row][0];
var totalCellData = totalValues[row][0];
if (soldCellData !== "" && totalCellData !== "") {
totalValues[row][0] = totalCellData - soldCellData;
}
}
loadRange.setValues(soldValues);
totalRange.setValues(totalValues);