Last active
August 10, 2018 19:23
-
-
Save fbentele/4df2b87e6c7fd1c880e5e66ecde3349f to your computer and use it in GitHub Desktop.
Stopwatch Google App Script für Waldi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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