Since the RAND() function in Google Sheets updates every time a cell is edited, I've been trying to make a Google Apps script which reads the randomly-generated value of a specific cell, to then store it in a variable for later use.
I've managed to set up the program to do so, but whenever I run it it seems to be reading a different random value than that actually displayed in the cell.
Here's the simple code:
function CopyPaste(){
var KanaSpreadsheet = SpreadsheetApp.getActive();
var KanaSheet = KanaSpreadsheet.getSheets()[0];
Logger.log(KanaSheet.getRange('I8').getValue());
//cell I8 is just simply set to =RAND()
}
I'm running the code with cell I8 set to "0,4356...", but Apss Script's Log actually displays a different value of "0,6741...". The wierd thing is that the value in cell I8 actually stays the same (since I'm not modifying the sheet), just as running the code multiple times in a row still gives the same value of "0,6741...". Is Google Apps Script reading on a "version of the sheet" "different" from the one that is being displyed in Google Sheets, or am I just missing something on how reading random values works?
PS: I'm new to Apps Script, but I haven't managed to find documentation online on this kind of problem.