Alex6361 wrote: ↑Fri May 10, 2024 3:43 am
... I was aware that a user-defined-function could not change the value of cells other than the cell it was called from via its return value, ...
The mentioned restriction
only is in force for cells of the same sheet. It was more than once relieved for LibO, but later reinstated, and I never tested if it also inhibits changes to UserDefinedProperties of the currently evaluating cell.
Alex6361 wrote: ↑Fri May 10, 2024 3:43 am
... but didn't extend that thinking to UserDefinedAttributes for a cell, ... So, thanks for correcting my bad assumptions!
Extending thinking is a good idea. However, It may not lead to a specifically recommendable solution if it isn't practised to the needed extent.
Here: Custom properties are possibly not the final hit.
Comes a part which I don't clearly understand, probably because I have no Excel 5.0 to test anything.
Alex6361 wrote: ↑Fri May 10, 2024 3:43 am
The user-defined-function (UDF) I'm trying to convert from an Excel workbook solves a problem through iteration based on the arguments (cell ranges) it is called with. ...
... the number of iterations can be drastically reduced if the guess can be the result it {the UDF ?} last calculated, ...
... Excel 5.0 and its VBA allows a UDF to get what was displayed in the cell at the time of the call, before the UDF then goes on to change it.
First time that I read about this interesting feature. How do you access this "ResultBeforeRecalculation" in your VBA UDF?
Alex6361 wrote: ↑Fri May 10, 2024 3:43 am
That allowed my UDF to start with that value and then go on to refine it, rather than start with a guess. So far, I have not been able to find a way to get that from CALC and StarBasic, so thought maybe the userdefinedattribute might be a way. Unfortunately, it's not.
StarBasic has no means for this, and I'm afraid there isn 't sufficient support for it even by the RAM representation of a Calc document.
Alex6361 wrote: ↑Fri May 10, 2024 3:43 am
I'll mark this as SOLVED, inasmuch as Tibor answered my original question with the fact that what I was trying to do can't be done. However, I still haven't found a way to get CALC Basic to do what Excel VBA could do 30 years ago.
Excel VBA is basically different from a programming languiae. It is a huge apparatus containing lots of "knowledge" specifically about the respective Excel version. Regarded as a lanuage it's mainly outdated. (I think I can state this though not using it because I sudied lots of Excel-VBA-code in pursuit of questions in forums and help sites.)
Alex6361 wrote: ↑Sat May 11, 2024 5:42 am
Thanks for the suggestions. ...
... but there are over 50 sheets in the workbook that have a cell calling this UDF, so I'd have to come up with a way to associate each UDF call with ...
... My work-around solution for now is to run a sub which goes through all of the sheets in the workbook looking for named cells {How do you name cells? Are you talking of named ranges/expressions?} ...
Concerning the "SOLVED" you learned already that it was too rash. There may be (e.g.) a sheet event allowing to trigger the needed process to store old values to user defined properties, but ...
Alex6361 wrote: ↑Fri May 10, 2024 3:43 am
Tibor, it isn't obvious to me what kind of Event might be used to initiate the saving of the last result for the next time external to the UDF. ...
Nor do I know one, but @Zizi64 may have an idea.
My so far "best" idea is to integrate the creation of a history of previous values for specific cells with the help of a "framing" UDF ...
I even made a "simple" example, and I will supply it as an attachment and explain it a bit if you ask an apropriate question in this
Macro forum like "How to make specific cells history aware?"
To post my suggestions in this thread would be a violation of the given subject.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München