Is it possible to have a function output its result to a different cell?

I am creating an ods I want to share with other people (users)

Some of the cells I want to display EITHER the result of a function (or one of several possible functions defined by a data validation drop-down list in a different cell), OR direct user input.

First possible solution I looked for was some function which allowed for “user input” as one of its possible results. I have been unable to find one.
The topic description is the next possible solution I have sought, and would be preferable I think. Still no luck so far.

I have spent apx. 1 full day searching already.

EDIT_For additional detail and clarification.

My .ods is for D&D 5e Character Building.
It will be protected and shared, so other players in my group can input relevant data but most of the data and functions will be in protected cells and hidden sheets.
The details below are not actually accurate to my .ods , instead they are simplified for clarity and to avoid posting pages worth of irrelevant detail/code.
If I find a solution, I will want to replicate it for several uses in my .ods .
I am using this project as a learning tool in order to utilise spreadsheet skills in other more important projects.

What I have

-A cell in Sheet 1 {'CombatStats’A1} which will display the characters Armour Class (AC).
-A cell in Sheet 2 {‘Equipment’.B2} which is a drop-down list for Armour Type.
-A sheet that will be hidden {‘ArmourData’}, with a range of cells {C3:D5}, which forms a table with “Armour Type” and “Formula” as columns.

{‘Equipment’.B2} is the dropdown list. It allows empty cells. Its source is the “Armour Type” column {$‘ArmourData’.C3:C5} .It works without problems or errors.

Each Cell in the “Formula” column of the table in {‘ArmourData’} has its own function to calculate AC. Each of those functions is of the form…
=IF($‘Equipment’.B2=“ArmourType1”; [Specific AC Formula for ArmourType1])
This calculates the ArmourType specific formula only if the dropdown list has that ArmourType selected, otherwise it outputs “FALSE”
All of these formula were working as intended with the dropdown.

What I want

I want the cell {'CombatStats’A1} to essentially be an automatic toggle which will
-EITHER–Allow the user to directly input their AC value
-OR--------Display the contents of the ArmourType Formula associated with the ArmourType selected in the drop-down list if there is nothing already entered in the cell

What I tried

I set the first cell in the drop-down list table in {‘ArmourData’.C3} as “User Input” and left the associated formula cell {D3} empty.

In the {'CombatStats’A1} “AC” cell, I tried…
=IFS($‘Equipment’.B2=$‘ArmourData’.C4;$‘ArmourData’.D4;$‘Equipment’.B2=$‘ArmourData’.C5;$‘ArmourData’.D5; $‘Equipment’.B2=$‘ArmourData’.C3;[ ])
I looked for a code/option that I could enter in place of the [ ] in the above function that would basically say “allow the user to directly enter a value into this cell” .
I could not find one.
Other than that, the function was working perfectly.
I also tried a few variations on that function, as well as other functions including nested IF functions.
All of them fail because any direct entry into a cell automatically overwrites any formula therein.

What I want to try next

Is the question in the title/topic of this post.

Is it possible to have each of the different “ArmourType” functions in the second column of the ‘ArmourData’ sheet print/output their result to the {'CombatStats’A1} “AC” cell?
So something along the lines of
=IF(‘Equipment’.B2=$‘ArmourData’.C5; IF(['CombatStats’A1 is empty]; [calculate Specific AC Formula for C5] THEN [Display the result in the cell {'CombatStats’A1}]; FALSE)FALSE)
So in effect it would
-Check what Armour Type is selected in the drop down.
-Check whether the “AC” cell in {'CombatStats’A1} already has anything written in it.
IF NOT
-Calculate the AC based on the Armour Type selected.
-Print/display/output the result in the “AC” cell in {'CombatStats’A1}

Another, less optimal, workaround I am considering is simply to have a 2nd space for “AC” alongside the {'CombatStats’A1} cell and just obscure their presentation with formatting.
I could then leave one cell/space for user input, have the other cell for function output, and include a “check if empty” clause in each of the specific AC functions.
This would work, but it would leave the formatting/presentation of the “AC” cells/fields less than neat, which is a strong preference for this, and future, projects.

I am realy hoping this has clarified my question and intended outcome, rather than making it more confusing and needlessly complicated.

Welcome!
Perhaps you was looking for the wrong thing.
Most likely, correct configuration of the drop-down list will solve the problem. Have you looked at the Data - Validity - Error Alert tab - Show error message when invalid values are entered checkbox? Have you tried to take it off?

1 Like

Hello JohnSUN, and thank you for the response.

I suspect I was not clear or detailed enough in my original post.
I was not getting errors from my functions.
My drop down list is working fine and is not central to my question, merely a side-note.

I will provide more detail in an edit to my original post now.

Hello @hatms

I am thinking to use ChatGPT (OpenAi) for helping in LibreOffice support (see my thread)
I am testing ChatGPT with some questions here. I tried with your question.

If you want to see an answer from OpenAI 3.5, fill free to follow this link.
I think, you should be able to improve the question.
https://chat.openai.com/c/e1df5ebe-6d1c-41ed-88d7-15caea66c768

Have a nice day, José from France.

Just on request, I can delete my answer :slight_smile:

These ChatGPT links are quite useless as opening them apparently requires an account with them. Apart from that, I wouldn’t trust ChatGPT’s solutions as far as I could throw it.

4 Likes

Sorry for my mistake with the link.
Use: Calc Data Validation Functions

What you ask in the title is not possible. The returned value of a function, aka result is used at the place where the function is written. Basic point of functional programming. Side effects usually not desired by concept.
.
You can only use a second cell to mirror the result and add further conditions or use a macro, as a SUB-routine is not necessarily a function.

2 Likes

Thank you. Sincerely thank you.
I can happily stop searching the hay stack now I know there is no needle.
I suspect Macro’s will be beyond me.
Work arounds it will be :slight_smile:

I apologize if this was a simple and obvious question. Last week my knowledge of spreadsheets did not extend much beyond “They have cells in a grid and they can do maths”

I re-read the description of the problem several times, but honestly, I didn’t fully understand the relationship between the data and the meaning of using the IF() function in calculations. Maybe it’s because I’ve never played D&D (I saw it several times in the television sitcom The Big Bang Theory, but didn’t understand much). Therefore, if the proposed file does not meet your goals, then simply ignore it as an incorrect solution to a misunderstood problem.
FunctionOrUserInput.ods (10.8 KB)
Here, CombatStats.A1 contains a drop-down list of one value - the only non-blank one, which is calculated using formulas with the IF() function in cells ArmourData.D3:D5 - and allows you to either select this value, select a blank value, or enter your own value in this cell. This seems to be what you asked for.
Just below there is another drop-down list - there you can select any value calculated by the functions, or enter your own (in this case there is no need for a drop-down list on Equipment.B2 - not several drop-down interconnected lists, but one with the possibility of user input.
The cell next to the dropdown list decodes the value as a text string.

And yes, user input is provided precisely by unchecking the checkbox, which I wrote about earlier.

1 Like

Ugh… Holy S… ahem.
I am an even bigger fool than I first gave myself credit for.
I owe both you, and myself, an apology.

I had tried messing with the error check box, but I had not tried placing the drop-down in the user-facing/top level of the sheet/logic. Since I was not even getting errors from the thing I assumed I had failed to articulate the issue in the first post but never considered that you might have skipped past the detail and gone straight to a solution to what I ACTUALLY wanted, rather than simply answering the question I had POSTED.

You, sir, are a Level 20 Wizard with max INT and double proficiency bonus in the spreadsheet skill.

Or at least seem so to my Lvl 1, barely-past-the-first encounter Barbarian.

It seems to me that what you got in the previous solution is still not what was required.
Somehow this is ugly different from the usual, classic user interface - select some incomprehensible number from the list or enter a number from the keyboard and then in the next cell you will see whether you are in light or heavy armor… Kind of nonsense, isn’t it?

It seems more correct to select the meaningful words “Medium Armor” from the list and next to it get a numerical value for further calculations. Or enter a number in a cell, for example, 45 and get the inscription “User Defined 45” and next to the number 45 (the one for calculations)

It seems to me that users who know at least something about computers will be more satisfied with this design than the previous one.
FunctionOrUserInput 2.ods (10.7 KB)

But now it was a little offensive… However, I forgive you - I know that barbarians do not know how to count to 80.