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

237
Visualizações
How can I manually change a cell's contents when I have a script to automatically set that cell?

I have created the below script:

function onEdit() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getSheetByName("Sheet1");
var cell = sh.getRange("A1:A1");
var cells = sh.getRange("B1:B1");

 if( cell.getValue() !="" ) {
 cells.setValue(new Date()); 

 }
 if( cell.getValue()==="" ) {
 cells.clearContent();
 }
}

This code can insert a new date into cell B1 when data is entered into cell A1. It can also remove the date from cell B1 when I clear the data from cell A1. But if I want to manually change the date in cell B1 when cell A1 has data entered, how can I do that?

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

You try this function

function onEdit(e) {let cellDate=e.source.getActiveSheet().getRange('B1');
    if(e.range.getA1Notation()=='A1'&&e.source.getSheetName()=='Sheet1')
       {if(e.value==null) cellDate.clearContent();
        else cellDate.setValue(new Date());}
}

Note: This function checks if the changed cell is A1, then makes the change to B1. So you can completely change B1 after you have changed A1

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