12

I apologise if this has been asked before but I've looked for an example and unfortunately I'm unable to find an answer hence why I'm asking here.

If I have a custom function in a Google Spreadsheet how do I get the value of a cell if the contents are dynamically generated. I can get the value when it's a fixed value but not when it's dynamic.

Rubén
  • 34,714
  • 9
  • 70
  • 166
user1408643
  • 731
  • 2
  • 7
  • 14
  • 1
    Posting the code of the custom function and the function as you enter it into the spreadsheet with required arguments would better enable lucid help. – ScampMichael May 21 '12 at 19:57

1 Answers1

19

Here's an example of getting the adjacent cell's value whether it's dynamic (created with a function or it's a flat value)

function getAdjacentValue() {
  var range = SpreadsheetApp.getActiveRange();
  var col = range.getColumn();
  var row = range.getRow();
  var range2 = SpreadsheetApp.getActiveSheet().getRange(row,col+1);
  return range2.getValue();
}
mzimmerman
  • 910
  • 6
  • 13