c0sm0s
c0sm0s

Reputation: 1

Google Sheets - Copy Cell -> Clear Cell -> Paste Cell

To work around my script/function refreshing it's calculation I had a script running that would copy the formula, clear the cell, and put the formula back in.

However, my script was somehow edited and now I can't figure out how to code this back...all I have is this base code that is not working and I don't remember how I made it work before...

I am missing a line or two of code but been racking my brain for a few hours =(

function RefreshSignups() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRange('L27:T29').activate();
  spreadsheet.getActiveRangeList().clear({contentsOnly: true, skipFilteredRows: true});
  spreadsheet.getRange('K26').activate();
 spreadsheet.getCurrentCell().setValue('REFRESH');
};

Upvotes: 0

Views: 55

Answers (1)

Benibis
Benibis

Reputation: 36

Right now you're not actually copying any data / formula, nor pasting them back.

You probably want to use something like this:

var copyRange = spreadsheet.getRange('L27:T29');
var data = copyRange.getFormulas();
copyRange.clear({contentsOnly: true, skipFilteredRows: true});
copyRange.setFormulas(data);

But to be honest, I'm not sure I fully understand what you're trying to achieve with this, so might be good to provide more details about your goal if the above doesn't address it.

Upvotes: 1

Related Questions