Spreadsheet screenshotI have a script from one of the old topics to copy row when a certain value is in a cell:
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = event.source.getActiveSheet();
var r = event.source.getActiveRange();
if(s.getName() == "Stock" && r.getColumn() == 4 && r.getValue() <= 5) {
var row = r.getRow();
var numColumns = s.getLastColumn();
var targetSheet = ss.getSheetByName("Orders");
var target = targetSheet.getRange(targetSheet.getLastRow() +1, 1);
s.getRange(row, 1, 1, numColumns).copyTo(target);
}
}
However, I need to make a thresholds for a categories. Let's say i have 2 categories in the stock: "Power Tools" and "Hand Tools". In case of Power tools i would like the script to run when the value reach 5 or less and in case of Hand Tools 10 or less. Category is set in column A and it have been set before so the trigger doesn't work when i write to conditions in the code as i changed only the amount value. Many thanks for advice!