Skip to content

Instantly share code, notes, and snippets.

@fbentele
Last active August 10, 2018 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbentele/4df2b87e6c7fd1c880e5e66ecde3349f to your computer and use it in GitHub Desktop.
Save fbentele/4df2b87e6c7fd1c880e5e66ecde3349f to your computer and use it in GitHub Desktop.
Stopwatch Google App Script für Waldi
function startAll() {
startB();
startE();
startH();
startK();
}
function startB(){
startTime("B");
}
function startE(){
startTime("E");
}
function startH(){
startTime("H");
}
function startK(){
startTime("K");
}
function startTime(column) {
var timeNow = Utilities.formatDate(new Date(), "GMT+2:00", "''HH:mm:ss")
var currentCell = findLastIndex(column);
var nextCell = currentCell + 1;
var sheet = SpreadsheetApp.getActiveSheet().getRange(column + nextCell).setValue(timeNow).setNumberFormat("HH:mm:ss");
}
function findLastIndex(column) {
var lastRow = SpreadsheetApp.getActiveSheet().getMaxRows();
var values = SpreadsheetApp.getActiveSheet().getRange(column + "1:" + column + lastRow).getValues();
for (; values[lastRow - 1] == "" && lastRow > 0; lastRow--) {}
return lastRow;
}
function clearAll() {
SpreadsheetApp.getActiveSheet().getRange('B6:B26').setValue("");
SpreadsheetApp.getActiveSheet().getRange('E6:E26').setValue("");
SpreadsheetApp.getActiveSheet().getRange('H6:H26').setValue("");
SpreadsheetApp.getActiveSheet().getRange('K6:K26').setValue("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment