I have the following onEdit(e) Google Apps Script which populates columns A:D in the next row of another sheet. I now want it to populate columns B:E and in Column A of the same row to populate with the text "SOP":
{
var spreadsheet = e.source;
var sheet = spreadsheet.getActiveSheet();
var sourcesheetname = "SOP Register"
var range = e.range;
var sheet = range.getSheet();
var row = range.getRow();
var column = range.getColumn();
var editedColumn = range.getColumn();
var editedRow = range.getRow();
var column = 7;
var date = range.getValue();
if(Object.prototype.toString.call(date) === '[object Date]' && editedColumn == column && editedRow > 3 && sheet.getName() == sourcesheetname) {
var targetsheetname = "Internal Audit Register";
var target = e.source.getSheetByName(targetsheetname);
var numCols = sheet.getLastColumn();
var values = sheet.getRange(row, 1, 1, numCols).getValues()[0];
values.splice(7)
values.splice(0, 0)
values.splice(1, 0)
values.splice(2, 3); // Removing undesired values
var lastRow = target.getLastRow();
var lastCol = target.getLastColumn();
target.appendRow(values); // Append new row
sheet.hideColumns(6,2);
}
}
Below is my Source Sheet:
Below is the target sheet data after the script:
This is my desired outcome:
This is a sample of my spreadsheet. The script code starts at line 67.
Just not sure how to do this.