Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

155
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda