Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

177
Vistas
How to get the next empty row in a specific column google spreadsheet using google apps script

I want to update the next rows in a spreadsheet with some data and for that, I need to find the last row. However, I need to get the last value in column A and not other columns. The function below works well and gets me the last row in column A that has value but returns that one and I need the row below the one with the value.

function getLastDataRow(sheet) {
  var lastRow = sheet.getLastRow();
  var range = sheet.getRange("A" + lastRow);

  if (range.getValue() !== "") {
    return lastRow;
  } else {
    return range.getNextDataCell(SpreadsheetApp.Direction.UP).getRow();
   }              
}

I am new to both JavaScript (python user) as well as Google Apps Script so I could really use some help with this as I have been trying all evening to get the first row in column A that is empty after the one with the value. For example if A20 has the last value, I want to return 21 and not 20.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Basically, I was using the following code to get a range and update the cells with new content:

if (projdoc.match(regExp)) { 
projdocnum = regExp.exec(projdoc)[1]; 
var target = "A" + (getLastDataRow ( sheet )+1); 
var regExp2 = new RegExp("[A-Za-z]+([0-9]+)","g"); 
var targetnum = regExp2.exec(target)[1]; var rangesheet = sheet.getRange(target+":D"+targetnum);
rangesheet.setValues([[ID, projectname, projdoc, projdocnum]]);
}

The only thing I changed was in earlier versions I had :

var target = "A" + (getLastDataRow ( sheet )); and I just added +1 to it to get the next row. 
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda