Help Programming a function

Keyboard macros or custom scripts
Post Reply
Grayedoutone
Posts: 2
Joined: Mon Nov 20, 2023 7:23 pm

Help Programming a function

Post by Grayedoutone »

Hello all, thank you in advance for any help! I have no experience with the programming languages OpenOffice uses. What I need, is a function that acts like the VLOOKUP function, but rather than copying the cell results of the table I need to copy the actual function inside the referenced cell. Is that even possible?
OpenOffice.1.14 on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11243
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Help Programming a function

Post by Zizi64 »

A custom macro Cell Function written in StarBasic can modify only that cell (or cells - when it is an array function) where it was called from.
Tibor Kovacs, Hungary; LO6.4.7-7.4.6 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.5.4;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
FJCC
Moderator
Posts: 9097
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Help Programming a function

Post by FJCC »

Here is an example of what I think you want. Enter a, s, or d in A2 and the formula in A1 will search column C for a match and return the formula from the appropriate cell in column E.
Out of curiosity, why do you want to do this?
Attachments
GetFormula.ods
(8.38 KiB) Downloaded 17 times
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Grayedoutone
Posts: 2
Joined: Mon Nov 20, 2023 7:23 pm

Re: Help Programming a function

Post by Grayedoutone »

@Zizi64
"A custom macro Cell Function written in StarBasic can modify only that cell (or cells - when it is an array function) where it was called from."
That's all I want it to do. If the function could run the function of the referenced formula as if it were in that position on the spreadsheet.
Essentially I would like to make a database of formulas, with stacked If and lookup functions written for 30 positions on a spreadsheet. I've tried using Concatenate with row to get the copied to row position. But once I use the Data>Text to Columns>Tab to change it to a formula and format it to a new row position it looses cell references.
Formula and indirect also copy the row from original table row.
Essentially I want to be able to run the formula as written in the original cell in the designated cell.
Is that possible?
@FJCC
Thanks, I've tried that. However it just shows the formula from the referenced cell. I need it to conform the formula to the current cell i.e. adjust the row # to the copied row, adjust the referenced column to an equidistant column. As if you copied and pasted the formula from one cell to another. Also I need it to be a functional formula and not text.
OpenOffice.1.14 on Windows 10
FJCC
Moderator
Posts: 9097
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Help Programming a function

Post by FJCC »

I think what you want to do is not possible. Functions return a value, either text or a number. You seem to want the function to overwrite the formula of the cell containing the function. A function will not do that, judging from a quick test I ran, and, in any case, it defeats the purpose of a function if it gets overwritten when it is used.
If I have misunderstood your goal, please explain it again. If I have not misunderstood you, try explaining why you want to do this and someone may have a solution to your underlying problem.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
Zizi64
Volunteer
Posts: 11243
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Help Programming a function

Post by Zizi64 »

Also I need it to be a functional formula and not text.
The LO Calc has not Evaluate() function. You can mot make a working Formula from a formula like text by a Cell function.

You must use a Subroutine for this task. That can modify the formulas of other cells, but you must launch it manually (or by an event of some object).
Tibor Kovacs, Hungary; LO6.4.7-7.4.6 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.5.4;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Post Reply

Return to “OpenOffice Basic, Python, BeanShell, JavaScript”