1
votes

Really quick im trying to find in a column a empty cell and replace it for today´s date.

I have no idea why is not working. What can it be? Heres the code.

function ConfirmacionGarantia() {
  var ss = SpreadsheetApp.getActiveSheet();


  //Seteamos la fecha

  var d = new Date();

  var month = d.getMonth()+1;
  var day = d.getDate();

  var output = d.getFullYear() + '/' +
    (month<10 ? '0' : '') + month + '/' +
      (day<10 ? '0' : '') + day;


  for(var i=3; i<ss.getLastRow();i++)
      {
  if(ss.getRange(i,23) == null )
    {
        ss.getRange(i,23).setValue(output) 
    }
}  

SpreadsheetApp.flush();
}

Thanks a lot.

1
what is it doing? Does it not find the empty cell? Change cells that have contents? - That Dave Guy
Hi , i placed intentionally empty cells and it just skip them. :/ - Tomas Campos
Have you tried == "" instead of == null? - That Dave Guy
I did and didnt work :( - Tomas Campos
omg didnt see that ! thanks a lot That Dave Guy! - Tomas Campos

1 Answers

1
votes

Just realized I didn't actually 'Answer' this

The information you need is here: https://developers.google.com/apps-script/reference/spreadsheet/range?hl=ja#getValue()