Define global variables

I am trying to test some algorithms in LibreOffice Calc, and I would like to have some global variables visible in all cells / sheets. I searched the Internet, and everything I saw is so mysterious and verbose!

I would appreciate if you could give me simple noob instructions (1 2 3 ...) on how I can do this.

+7
source share
3 answers

Using custom functions should be the most flexible solution for defining constants. In the following case, I assume that the current Calc spreadsheet file is called test1.ods. Replace it with the real file name in the following steps:

  • Calc → → → LibreOffice Basic:

    enter image description here

  • test1.ods New...:

    enter image description here

  • OK (Module1 ).

    enter image description here

    IDE:

    enter image description here

  • End Sub :

Function Var1()
    Var1 = "foo"
End Function

Function Var2()
    Var2 = 42
End Function

IDE :

enter image description here

  1. CTRL + S .

, (: , ). . LO Calc test1.ods, :

=Var1()

LO Var1(), . , . :

=Var2() * 2

LO 84.

+1

→ → . name "MyVar1" 5. , "foo". .

Define name

=MyVar1 * 2 .

cell formula

+7

, Variable Cell Default Name

, , "" , . Set Name for Cell / Range of Cells

Using Variable Name in Calculation

+2

Source: https://habr.com/ru/post/1689681/


All Articles