karlosos
karlosos

Reputation: 1174

Daily increment number

I want to solve this problem in simplest way.

How to daily increment value in specified cell or range of cells. For exemple in cell 'A1' i insert today value 15. Tommorow this value will be 16, day after tommorow 17 etc.

Upvotes: 0

Views: 4079

Answers (3)

pnuts
pnuts

Reputation: 59450

Please try in A1:

=now()-42010  

format as number, no decimals and in File, Spreadsheet settings... ensure Recalculation: is set to On change and something.

Upvotes: 0

Alan Wells
Alan Wells

Reputation: 31300

Another option is to add a time trigger or an onOpen() trigger to your spreadsheet. When you open your spreadsheet, the function would check the cell you are incrementing, get the last value, check if the last value is the value for the current day, and if it isn't add a new value.

function onOpen() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = spreadsheet.getSheets()[0];

  var cellValue = sheet.getRange("A1");
  var theDate = new Date().getDay();

  Logger.log('theDate: ' + theDate);

  var todaysNumber = theDate;

  if (cellValue != todaysNumber) {
    cellValue.setValue(todaysNumber);
  }; 
};

Upvotes: 0

Phil
Phil

Reputation: 2293

I dont think anything exists which will automatically go in to your spreadsheets and fiddle with your values. But you can use a formula based on some start date:

=DATEDIF(DATE(2015, 1, 6), TODAY(), "D")

This will calculate how many days there have been since 2015 Jan 6. Today for me the answer is 15, and tomorrow it will be 16.

Upvotes: 1

Related Questions