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

158
Vistas
app script google sheet getLastRow start from specific column to put data

I need to put data to sheet by app script using getLastRow to put every value under last value:

function addData(name, age, gender) {
      var ss= SpreadsheetApp.getActiveSpreadsheet();
      var sheet = ss.getSheetByName("Sheet2");
      var currentRow = sheet .getLastRow();
      var nextRow = currentRow + 1;
      sheet .getRange(nextRow,5).setValue(name);
      sheet .getRange(nextRow,6).setValue(age);
      sheet .getRange(nextRow,7).setValue(gender);
}

I have data using before column 5 and the data put after nextRow for column before not column 5

enter image description here

I want to put get the result like that:

enter image description here

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

0

The answer is:

function addData(name, age, gender) {
  var ss= SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Sheet2");
  var startcolumn = tableSheet.getRange("E1:E").getValues();
  var currentRow = startcolumn.filter(String).length
  var nextRow = currentRow + 1;
  sheet .getRange(nextRow,5).setValue(name);
  sheet .getRange(nextRow,6).setValue(age);
  sheet .getRange(nextRow,7).setValue(gender);
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

This will work provided the column you want to insert the value into is "clear" meaning there is no possibility of any old data or unempty cells below the placement point.

Change

var currentRow = sheet .getLastRow(); 

To

var currentRow = sheet.getRange(1,5).getNextDataCell(SpreadsheetApp.Direction.DOWN).getRow();
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