Reference a Cell Value from a Function

Is it possible to reference the value of a fixed cell from a function that I’m defining?

For example:

Function MyFunc(a) As Double
   MyFunc = a * A2
End Function

The cell A2 from which sheet? From the active sheet? Then the function will return different results depending on what kind of sheet now is active. You can pass in the function more than one parameter - the second parameter specify the address of the cell A2

Let’s say “Sheet1”.

OK. See Andrew Pitonyak book chapter “6.2. Display cell value, string, or formula” or function GetValueofCellbyName() in standard library Tools module Misc

The information provided in the comment by @JohnSUN against the question has answered this query. I am merely repeating that detail here. Andrew Pitonyak covers referencing the value of a spreadsheet cell in his works:

  • OOo Useful macro information (ODT), 6.2. Display cell value, string, or formula
  • OOo Macros explained (ODT/PDF), 15.2. Sheet cells contain the data

You can also make use of the provided macro function GetValueofCellbyName() under LibreOffice Macros & Dialogs > Tools library > Misc module.