I have the following problem. I want to have a value written to a line when a certain condition is met. The whole thing works currently also here my code:
function onEdit(e) {
addTimestamp(e);
}
function addTimestamp(e) {
var ui = SpreadsheetApp.getUi();
var ws = "Tabellenblatt2";
var targetSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Tabellenblatt1");
var range = targetSheet.getRange(3, 2, 1000,1);
var currentDate = new Date();
if(e.source.getActiveSheet().getName() === ws && range != "") {
var cell = SpreadsheetApp.getActiveSheet().getActiveCell();
var val = cell.getValue();
if (val != "") {
let rowToAdd = [val, "", currentDate, ""]
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Tabellenblatt1").appendRow(rowToAdd);
ui.alert("Test2");
}
if (val === ""){
let rowToAdd = ["", "", "", currentDate]
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Tabellenblatt1").appendRow(rowToAdd);
ui.alert("Test3");
}
}
}
I want the second If statement to put the value in the same line as in the first If statement, so that no new line is created. Does somebody has any idea?
I want the second If statement to put the value in the same line as in the first If statement, so that no new line is created.
? Aboutthe same line as in the first If statement
, how do you check this? For example, when there are several rows bythe first If statement
, where do you want to put the value asthe same line as in the first If statement
? - Tanaikehow to tie the line to it so that it works with multiple lines
, I cannot understand about your goal. So in order to correctly understand about your goal, can you provide the sample situation including the input and output you expect? By this, I would like to confirm it. - Tanaike