0

I have programmed a macro in Google Sheets that displays a table to show the history of certain data that changes every day. Every day the macro inserts a new line with a new date into the table. This is done using a trigger. Problem: The trigger always puts in the data on the first sheet, but my Evaluation list is the 6th sheet and called Evaluation. What do I have to enter into the code so that the values are entered on the 6th sheet (evaluation)?

 var tabellenblatt=SpreadsheetApp.getActiveSheet();
 var aktuellerZeitpunkt=new Date();
 var zeitStempelFormat="dd.mm.yyyy hh:mm:ss";

 tabellenblatt.getRange(tabellenblatt.getLastRow()+1,56).setValue(aktuellerZeitpunkt).setNumberFormat(zeitStempelFormat);
 var checklist=SpreadsheetApp.getActive().getSheetByName("Phase 1-6 checklist");
 var currentValue1=checklist.getRange("BJ406").getValue();
 var currentValue2=checklist.getRange("BK406").getValue();
 var currentValue3=checklist.getRange("BL406").getValue();
  tabellenblatt.getRange(tabellenblatt.getLastRow()+0,57).setValue('=\'Phase 1-6 checklist\'!BH406');
   tabellenblatt.getRange(tabellenblatt.getLastRow()+0,58).setValue('1-6');
  tabellenblatt.getRange(tabellenblatt.getLastRow()+0,59).setValue('=\'Phase 1-6 checklist\'!BJ406').setValue(currentValue1);
 tabellenblatt.getRange(tabellenblatt.getLastRow()+0,60).setValue('=\'Phase 1-6 checklist\'!BK406').setValue(currentValue2);
 tabellenblatt.getRange(tabellenblatt.getLastRow()+0,61).setValue('=\'Phase 1-6 checklist\'!BL406').setValue(currentValue3);
}```
greenster10
  • 79
  • 1
  • 9
  • Has anyone got an idea? – greenster10 Nov 08 '19 at 07:50
  • Yes, the idea is to read [ask] and then [edit] your question and add your code. Because it is impossible to help you with your code if we don't see what you did. – Pᴇʜ Nov 08 '19 at 08:33
  • the code is pretty useless in this case I guess, but can you help me? – greenster10 Nov 08 '19 at 08:53
  • 1
    i posted the code in the question – greenster10 Nov 08 '19 at 09:16
  • You set here to use the active sheet `var tabellenblatt=SpreadsheetApp.getActiveSheet();` If you want to use any other sheet you must set your other sheet there. • Your code is never useles, because it shows what you have done/tried so far. – Pᴇʜ Nov 08 '19 at 09:47
  • so: ```var tabellenblatt=SpreadsheetApp.getActiveSheet(Evaluation);``` Like this? OR: ``` var tabellenblatt=SpreadsheetApp.Evaluation();``` Like This? – greenster10 Nov 08 '19 at 09:49
  • like this: [Get Sheet By Name](https://stackoverflow.com/questions/48867655/get-sheet-by-name) – Pᴇʜ Nov 08 '19 at 10:58
  • TypeError: SpreadsheetApp.getsheetbyname is not a function - that doesn't work :( – greenster10 Nov 08 '19 at 12:20
  • ok now it works, thank you, had to add .getActive() in between SpreadsheetApp.getsheetbyname! – greenster10 Nov 08 '19 at 12:39
  • Possible duplicate of [Get Sheet By Name](https://stackoverflow.com/questions/48867655/get-sheet-by-name) – Pᴇʜ Nov 08 '19 at 15:27

0 Answers0