0

Any idea how to get lastRow at certain column, in this case i want the lastRow for range AJ until AX only.

  var emailUser = Session.getActiveUser().getEmail();
  var ss2 = SpreadsheetApp.openById('1h2jmWV7mytPF_ltxYb2uPm4Pq7iHLg-hc3k_0X4Txvw');
  var ws2 = ss2.getSheetByName(emailUser);
  var lastRow = ws2.getLastRow();
  var rdPic = ws2.getRange(3,36,lastRow,50).getValues();
  var lrPic = rdPic.filter(String).length + 1;

  ws2.getRange("AJ"+lrPic).setValue(stock.tglMasuk1);
  ws2.getRange("AK"+lrPic).setValue(stock.namaPic1);
  ws2.getRange("AL"+lrPic).setValue(stock.locPIC1);
  ws2.getRange("AM"+lrPic).setValue(stock.teritori1);
  ws2.getRange("AN"+lrPic).setValue(stock.penyimpanan1);
  ws2.getRange("AO"+lrPic).setValue(stock.jenisTransaksi1);
  ws2.getRange("AP"+lrPic).setValue(stock.nmrDO1);
  ws2.getRange("AQ"+lrPic).setValue(stock.tglDO1);
  ws2.getRange("AR"+lrPic).setValue(stock.sn1);
  ws2.getRange("AS"+lrPic).setValue(stock.venname1);
  ws2.getRange("AT"+lrPic).setValue(stock.itm1);
  ws2.getRange("AU"+lrPic).setValue(stock.ponum1);
  ws2.getRange("AV"+lrPic).setValue(stock.bcd1);
  ws2.getRange("AW"+lrPic).setValue(emailUser);
  ws2.getRange("AX"+lrPic).setValue(dateNow);
Caine0027
  • 3
  • 2
  • Try using getColumnHeight() in this answer: https://stackoverflow.com/a/55425107/7215091 – Cooper Jun 17 '21 at 02:49
  • Hi I understand you could solve your issue? If that's the case, can you post answer explaining how you did this? (I'm not sure whether you wanted to retrieve the last row with content in certain columns, or just the values of the last row in those columns). – Iamblichus Jun 17 '21 at 07:34
  • Hi, solved by changed only this var rdPic = ws2.getRange("AJ:AJ").getValues(); so i will get the lastRow between column AJ:AX only. – Caine0027 Jun 17 '21 at 12:59
  • I don't see how using `var rdPic = ws2.getRange("AJ:AJ").getValues();` will get you the lastRow between `AJ:AX`. Can you clarify? – Iamblichus Jun 18 '21 at 08:03
  • Yes, it will add new value in to the next row, but the cell AJ must filled something, then the value will be add to the next row. – Caine0027 Jun 21 '21 at 10:01

0 Answers0