0

I have a google sheet that I want to add a time stamp every time a cell was updated. I have the basic code down:

function onEdit() { 
    var s = SpreadsheetApp.getActiveSheet(); 
    var c = s.getActiveCell();  
    var cell1 = 13 
    if(c.getColumn() != cell1 ) { 
        var row = c.getRow();  
        var time = new Date(); 
        time = Utilities.formatDate(new Date(), "EST", "MM-dd-yyyy HH:mm:ss");
        SpreadsheetApp.getActiveSheet().getRange(row,cell1).setValue(time); 
    };
};

But I want to only trigger it on 1 sheet called "VariableMaster" so I tried:

if(c.getColumn() != cell1 && s == "VariableMaster") {....

I also tried adding another if statement below that

 if(c.getColumn() != cell1 ) { 
      if(s.getActiveSheet == "VariableMaster"){...

Both attempts breaks the function and it doesn't add the time stamp to any sheet. Thanks!

1 Answer 1

2

The parameter you want to check is the sheet name so you have to compare the sheet Name.

Use if(c.getColumn() != cell1 && s.getName() == "VariableMaster") {....

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.