Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

228
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!