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

268
Visualizações
How do I get my code on google sheets to cover multiple tabs?

I have a code that runs on my google sheets every time someone fills out a form online which pushes info into my CRM Software. It pulls the info in great off of the main tab; but how can I get the script to run for multiple tabs on the same spreadsheet? I tried a couple solutions but couldn't figure it out. this is the current code

var sheet = SpreadsheetApp.getActiveSheet();

var scriptProperties = PropertiesService.getScriptProperties();   
var lastRange = scriptProperties.getProperty("last_range");

//Logger.log("Debug:" + lastRange);

if (!lastRange) {
  var lastRow = sheet.getDataRange().getLastRow() + 1;
  scriptProperties.setProperty("last_range", "A" + lastRow);
  lastRange = scriptProperties.getProperty("last_range");
}

var range = sheet.getRange(lastRange);
var totalRange = sheet.getDataRange();
var isBlank = range.isBlank();
var isGreater = false;
 
about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

You are currently using:

var sheet = SpreadsheetApp.getActiveSheet();

Where you should be using:

var sheet = SpreadsheetApp.getActive().getSheetByName(sheetName);

You haven't specified which tabs (sheets) you have, but it should be a simple case of dropping in the appropriate sheet name in the function above.

See https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet#getSheetByName(String)

about 4 years ago · Santiago Gelvez 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