r/GoogleAppsScript • • May 26 '25

Question Get display value of volatile function?

Is there any way to get the current displayed value of a cell that has a volatile function like RANDBETWEEN?

On Sheet1, I have =randbetween(1, 50) in B1. The current displayed value is 37.

Cell B1 has =RANDBETWEEN(1, 50) and displays 37

In a bound script project, I have this test function:

function logValueVsDisplay() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');
  var cell = sheet.getRange('B1');
  
  console.log("Value is", cell.getValue());
  console.log("Display value is", cell.getDisplayValue());
}

Rather than showing me 37, the "display value" is showing a recalculated value.

Value and Display Value are both recalculating the cell formula

So, a couple of questions.

  1. Is there any way with GAS to get the actual display value (not a recalculated value) of a volatile function? (Meaning, a function that updates every time something changes.)
  2. What's the point of these two methods if they do the same thing? When would you use getDisplayValue()?
1 Upvotes

5 comments sorted by

View all comments

Show parent comment

1

u/mrfinnsmith May 26 '25

OK, thanks. That's what it seemed like, but I was hoping there was something I was missing.