Home > database >  How to put data from a custom dialog into a specific range in the sheet without using appendRow
How to put data from a custom dialog into a specific range in the sheet without using appendRow

Time:12-14

I'm having trouble putting data from a custom dialog into a specific range in the sheet, like this: enter image description here enter image description here

Everytime i enter new data in the dialog, it should append a new row in that particular range. So far i'm using appendRow for that matter but the problem with that is that appendRow counts in ALL columns in the sheet, so that i'm having blank cells in the particular range, like this: enter image description here

This is one of the codes i'm using :

//STUNDE EINTRAGEN VIA START
function showDialogKBSTART() {

  gotoSheetSchueler();

  var widget = HtmlService.createHtmlOutputFromFile("formKBSTART.html").setHeight(450).setWidth(450);
  
  SpreadsheetApp.getUi().showModalDialog(widget, "Stunde eintragen");
}

function appendRowFromFormSubmitKBSTART(formKBSTART) {
  
  SpreadsheetApp.getActiveSheet()
    .appendRow([formKBSTART.Datum, formKBSTART.Inhalt, formKBSTART.Sozialform, formKBSTART.Dauer, formKBSTART.Lehrkraft,, formKBSTART.Ausfall]);
  SpreadsheetApp.getActiveSpreadsheet().getSheetByName('KlassenbuchGesamt')
    .appendRow([SpreadsheetApp.getActiveSheet().getName(), formKBSTART.Datum, formKBSTART.Inhalt, formKBSTART.Sozialform, formKBSTART.Dauer, formKBSTART.Lehrkraft, formKBSTART.Ausfall]);

  SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange("A9:A").setNumberFormat("dd.MM.yyyy");
  SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange("A9:F").sort({column: 1, ascending: false});

  SpreadsheetApp.getActiveSpreadsheet().getSheetByName('KlassenbuchGesamt').getRange("B2:B").setNumberFormat("dd.MM.yyyy");
  SpreadsheetApp.getActiveSpreadsheet().getSheetByName('KlassenbuchGesamt').getRange("A2:G").sort({column: 2, ascending: false});

      Utilities.sleep(500);

  SpreadsheetApp.getActiveSpreadsheet().toast("Stunde eingetragen!","           
  • Related