I have the following script which is triggered by a tick box in column Y of each row of the "Events/Incidents" sheet:
// Copy and paste from Events/Incidents sheet to Vehicle Damage sheet
{var range = e.range;
var sheet = range.getSheet();
var row = range.getRow();
var column = range.getColumn();
var sourcesheetname = "Events/Incidents";
var checkbox = range.getValue();
if (sheet.getName() == sourcesheetname && column == 25 && row > 2 && checkbox == true) {
var targetsheetname = "Vehicle Damage";
var target = e.source.getSheetByName(targetsheetname);
var numCols = sheet.getLastColumn();
var values = sheet.getRange(row, 1, 1, numCols).getValues()[0];
values.splice(17)
values.splice(8, 8)
values.splice(5, 1)
values.splice(3, 1); // Removing undesired values
var lastRow = target.getLastRow();
var lastCol = target.getLastColumn();
target.appendRow(values); // Append new row
if (lastRow >= 3)
target.getRange(lastRow, 10, 1, 1).copyTo(target.getRange(lastRow + 1, 10, 1, 1), SpreadsheetApp.CopyPasteType.PASTE_FORMULA); //Copy and paste the formula in column J
target.getRange(lastRow, 19, 1, 1).copyTo(target.getRange(lastRow + 1, 19, 1, 1), SpreadsheetApp.CopyPasteType.PASTE_FORMULA); //Copy & paste the formula in column S
target.getRange(lastRow + 1, 1, 1, values.length + 12).setBorder(true, true, true, true, true, true, "white", SpreadsheetApp.BorderStyle.SOLID);
target.getRange(lastRow, values.length).offset(1, 1).activate();}
When the tick box is checked, the script copies columns A, B, C, E, G, H and Q from the ticked row of the "Event/Incident" sheet and pastes them sequentially into columns A:G of the "Vehicle Damage" sheet.
I found that users are ticking the checkbox before the cells in the "Events/Incident" sheet have been populated. I, therefore, want to stop the activation of the script until all of the cells A, B, C, E, G, H and Q from the ticked row of the "Event/Incident" sheet have been populated. I would also like a message to pop up telling the user that they must first populate the cells.
I would appreciate help with this.