I'm having trouble finding out how to get the last row of a specific column which has data in it (like this: Determining the last row in a single column) and implementing it together with "appendRow" in my code, so that I can append data to the next blank row in that specific column.
Here is an example sheet of what I have:
Everytime I want to append a row in ColA via dialog, the script gets the last row of all columns, not just of ColA.
Here is an example of the code I'm using:
//dialog 1
function showDialog1() {
var widget = HtmlService.createHtmlOutputFromFile("dialog1.html").setHeight(250).setWidth(700);
SpreadsheetApp.getUi().showModalDialog(widget, "Dialog 1");
}
function appendRowFromFormSubmitDIALOG1(formdialog1) {
SpreadsheetApp.getActiveSheet().appendRow([formdialog1.datadialog1]);
}
//dialog 2
function showDialog2() {
var widget = HtmlService.createHtmlOutputFromFile("dialog2.html").setHeight(250).setWidth(700);
SpreadsheetApp.getUi().showModalDialog(widget, "Dialog 2");
}
function appendRowFromFormSubmitDIALOG2(formdialog2) {
SpreadsheetApp.getActiveSheet().appendRow([,formdialog2.datadialog2]);
}
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script>
function submitForm() {
google.script.run.appendRowFromFormSubmitDIALOG1(document.getElementById("dialog1"));
document.getElementById("form").style.display = "none";
}
</script>
</head>
<body>
<div>
<div id="form">
<form id="dialog1">
<label for="datadialog1"><b>datadialog1</b></label></br>
<input type="text" id="datadialog1" name="datadialog1" size="60"><br><br>
<input type="button" value="submit" onclick="submitForm();google.script.host.close()">
</form>
</body>
</html>
So my question is how get the last row of a specific column and let "appendRow" write data from "appendRowFromFormSubmit" (see code example above) into the next blank row of that column.
Like this: