google apps script - Last Row, Last Column getting weird values? -


so, ive been trying , trying learn hell going on values of methods getlastcolumn , getlastrow, somehow throwing weird values since have filled in first 3 column until row number 30 should values number 3 , 30 right? im somehow getting weird values, 23 19 , on.

function golpeslocos(sheet, col, origv1, newv1, origv2, newv2) {   var ss = spreadsheetapp.openbyid("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");    var lrow = ss.getlastrow();   var lcol = ss.getlastcolumn();   browser.msgbox(lrow+"       "+lcol);   //spreadsheetapp.getactivesheet().getrange(1, 1).setvalue("probando");   var rows = 2;   /*var d= new date();   var rango = spreadsheetapp.getactivesheet().getrange(rows, lcol+1);   var notacion = rango.geta1notation();   var currenttime = d.tolocaletimestring();   (var i=1; < lrow; i++) {     ss.getrange(notacion).setvalue("probando "+currenttime);     rows++;   }*/  } 

i think dont why hell getting values? maybe soome cache related issue? dont quite it.

any thought highly appreciated.

thanks, enrique bravo.

you have more 1 sheet in spreadsheet. if call function getlastcolumn() or getlastrow() directly spreadsheet instead of sheet, default runs on first sheet (even if hidden) make sure gets values of sheet want, sheet before, can use:

getsheetbyname():

function myfunction() {   var ss = spreadsheetapp.openbyid("{your_id}");   var sheet = ss.getsheetbyname('hoja1')   var lrow = sheet.getlastrow();   var lcol = sheet.getlastcolumn(); } 

getsheets():

function myfunction() {   var ss = spreadsheetapp.openbyid("{your_id}");   var sheet = ss.getsheets()[1] // index of sheet   var lrow = sheet.getlastrow();   var lcol = sheet.getlastcolumn(); } 

Comments