FS93h‖

rYvdz‖User-Defined Functions

4PUhf‖You can apply user-defined functions in LibreOfficeDev Calc in the following ways:

H2JBv‖Defining A Function Using LibreOfficeDev Basic

  1. PfDpb‖Choose Tools - Macros - Edit Macros.

  2. N4uB4‖You will now see the Basic IDE.

  3. jXhZH‖In the Object Catalog window, double-click on the module where you want to store your macro.

  4. G6mwG‖Enter the function code. In this example, we define a VOL(a; b; c) function that calculates the volume of a rectangular solid with side lengths a, b and c:


    Function VOL(a, b, c)
        VOL = a*b*c
    End Function

3bcAE‖Copying a Function To a Document

Lm54u‖In stage 2 of "Defining A Function Using LibreOfficeDev Basic", in the Macro dialog you clicked on Edit . As the default, in the Macro from field the My Macros - Standard - Module1 module is selected. The Standard library resides locally in your user directory.

DBXEe‖If you want to copy the user-defined function to a Calc document:

  1. FiJEi‖Choose Tools - Macros - Organize Macros - Basic.

  2. HZciB‖In the Macro from field select My Macros - Standard - Module1 and click Edit.

  3. GAARi‖In the Basic-IDE, select the source of your user-defined function and copy it to the clipboard.

  4. GTEs8‖Close the Basic-IDE.

  5. rYyws‖Choose Tools - Macros - Organize Macros - Basic .

  6. oTBX8‖In the Macro from field select (Name of the Calc document) - Standard - Module1. Click Edit.

  7. F2mDo‖Paste the clipboard contents in the Basic-IDE of the document.

AkZ68‖Applying a User-defined Function in LibreOfficeDev Calc

cKHUA‖Once you have defined the function VOL(a; b; c) in the Basic-IDE, you can apply it the same way as the built-in functions of LibreOfficeDev Calc.

  1. WtG8F‖Open a Calc document and enter numbers for the function parameters a, b and c in cells A1, B1, and C1.

  2. TTo2C‖Set the cursor in another cell and enter the following:

    =VOL(A1;B1;C1)

  3. frbse‖The function is evaluated and you will see the result in the selected cell.