I am writing an action script in Google Sheets to copy a cell, paste it in another, then, ideally, clear the first cell. I have the copy and paste function working, but when it runs the clear on the copied field, it's also clearing the cell that it was pasted in.
Here is my code:
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Sheet1");
function copyAllInRange(){
var copyRange = sheet.getRange("K3");
var pasteRange = sheet.getRange("K2");
copyRange.copyTo(pasteRange);
copyRange.clear();
};
var run = copyAllInRange()
What I'm going for is:
- Copy contents of K3
- Paste contents in K2
- Clear K3
What's happening is when clearing K3, it's also clearing K2.