Formula for moving to Next Row

asked 2019-08-12 00:31:57 +0200

SoCalRob gravatar image

updated 2019-08-19 09:55:04 +0200

I have a time sheet set up so that when I click a button it enters the current time on a certain line but I can't formulate it to enter new time on the next row when I click it again...

                           Column D

Monday                   Current Time <---Entered correctly but does not move to next row

Tuesday                     Row 11

Wednesday                   Row 12

Thursday                    Row 13

Friday                      Row 14

Saturday                    Row 15

Sunday                      Row 16

This is what I have so far:

   function Clear() {
     var spreadsheet = SpreadsheetApp.getActive();
     spreadsheet.getRangeList(['C3', 'C9:D15', 'C19:D25']).activate()
     .clear({contentsOnly: true, skipFilteredRows: true});
 };

  function ClockIn() {
    var spreadsheet = SpreadsheetApp.getActive();
    spreadsheet.getRangeList(['C9', 'C10', 'C11', 'C12', 'C13', 'C14', 'C15']).activate()
    var date = new Date();
    date.setFullYear(1899, 11, 30);
    spreadsheet.getActiveRangeList().setValue(date)
    .setNumberFormat('h:mm am/pm');
};

  function ClockOut() {
    var spreadsheet = SpreadsheetApp.getActive();
    spreadsheet.getRangeList(['D9', 'D10', 'D11', 'D12', 'D13', 'D14', 'D15']).activate();
    var date = new Date();
    date.setFullYear(1899, 11, 30);
    spreadsheet.getActiveRangeList().setValue(date)
    .setNumberFormat('h:mm am/pm');
};

So how can I formulate this to go to the next line in the column when the button is pressed, and how can I loop it back to the beginning after so many entries? Any Ideas?

edit retag flag offensive close merge delete