This is a very simple question but I’m not being able to do it in GoogleSheets.
I want to execute an appscript that is able to read and write values in cells in different sheets without activating them.
Imagine that i’m in ‘sheet1’ and i want to copy A1 from ‘sheet2’ to B2 in ‘sheet3’ without activating sheet 2 or 3 – ie i want the screen to remain in the same sheet.
I really don’t know how to do this…
I’m around the lines of “getactivesheet” that always change the screen…
I’ve seen posts using sheets’ numbers but i want to use the names and not the numbers…
0
read and write values in cells in different sheets without activating them
Use Sheet.getRange()
, like this:
const ss = SpreadsheetApp.getActive();
const sheet = ss.getSheetByName('Sheet2');
const sourceCell = sheet.getRange('A2');
const targetCell = sheet.getRange('B4');
const value = sourceCell.getValue();
targetCell.setValue(value);
See Apps Script at Stack Overflow and Clean Code JavaScript.
2