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

225
Visualizações
onEdit Trigger Google Scripts

I've been working on a sheet to make a calculator that I'll use on my work, it has lots of custom functions, it's working fine. But I have like 10 functions that need to run, so I've used triggers to run those functions every time the sheet was edited. But it stopped working, and it was too resource heavy (running all the functions every time something was edited).

So how can I make a trigger function that will run one of my custom functions only if a specific cell value is edited?

In this example I want the function ifEntrada() to run when the value in cell B4 is altered:

function ifEntrada() {
  var calcular_range = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Apartamentos").getRange("B4");
  var calcular = calcular_range.getValue();
  if (calcular == "Inserir Valor Manualmente") {
    showRows_entrada_manual();
  } else {
    hideRows_entrada_manual()
  }
}

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Obviously you have declared triggers observing edits on the sheet which can easily run into rate limits. You have to use the built in funcion onEdit() instead:

function onEdit(e) {
  var activeRow = e.range.getRow();
  var activeCol = e.range.getColumn();
  if (activeCol == 2 && activeRow == 4) ifEntrada();  // "2" represents the B
}

function ifEntrada() {
  var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Apartamentos');
  // do things
}

Mind that edits done over a range with the monitored cell B4 within will trigger the onEdit function only if B4 is the first cell where the edit takes effect.

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