Hi,
Is it possible to use SpinButton or NumericalField with SpinButton enabled to increment certain value by a real number?
So each mouse click should either add or take 0.1 from current cell value.
How would I do that?
Thank you for your help!
[Solved] Increment by real value using SpinButton
[Solved] Increment by real value using SpinButton
Last edited by skrat on Thu Dec 07, 2017 2:28 pm, edited 1 time in total.
OpenOffice 4.1.4. Windows 10
Re: Increment by real value using SpinButton/NumericalField
The form control elements can handle the integer numbers only. But you can use ten times larger numbers, and you can divide the value of the linked cell by 10. See the sample file.
Tibor Kovacs, Hungary; LO7.5.8/25.8.5.2 /Win7-10-11 x64Prof.
PortableApps: LO3.3.0-25.8.5.2;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.
PortableApps: LO3.3.0-25.8.5.2;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.
Re: Increment by real value using SpinButton/NumericalField
I thought about that but it's not something I could accept. The reason is document readability.
By readability I mean not too much unnecessary numbers. I am only interested in real number (1.6) and not integer value (16). Obvious solution to that is to hide the column/row with integer values but this leads to a massive disadvantage I can't afford: By hiding the integer values I can't change the real value directly - meaning I can't type 10000.5 into cell (but at teh same time would take way to much mouse clicks to get to that number starting from 1.6).
I thought Macro might be the solution but I can't figure out how to identify which button of the SpinButton was pressed - increasing or decreasing one.
By readability I mean not too much unnecessary numbers. I am only interested in real number (1.6) and not integer value (16). Obvious solution to that is to hide the column/row with integer values but this leads to a massive disadvantage I can't afford: By hiding the integer values I can't change the real value directly - meaning I can't type 10000.5 into cell (but at teh same time would take way to much mouse clicks to get to that number starting from 1.6).
I thought Macro might be the solution but I can't figure out how to identify which button of the SpinButton was pressed - increasing or decreasing one.
OpenOffice 4.1.4. Windows 10
Re: Increment by real value using SpinButton/NumericalField
Put the linked cell onto an another (hidden) sheet, and the result of the dividing onto the main sheet.By readability I mean not too much unnecessary numbers. I am only interested in real number (1.6) and not integer value (16).
Tibor Kovacs, Hungary; LO7.5.8/25.8.5.2 /Win7-10-11 x64Prof.
PortableApps: LO3.3.0-25.8.5.2;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.
PortableApps: LO3.3.0-25.8.5.2;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.
Re: Increment by real value using SpinButton/NumericalField
Use the oEvent object to recognise the object that called the macro.I thought Macro might be the solution but I can't figure out how to identify which button of the SpinButton was pressed - increasing or decreasing one.
Examples:
viewtopic.php?f=20&t=90272&hilit=+oEvent
viewtopic.php?f=20&t=71770
viewtopic.php?f=45&t=62024
Tibor Kovacs, Hungary; LO7.5.8/25.8.5.2 /Win7-10-11 x64Prof.
PortableApps: LO3.3.0-25.8.5.2;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.
PortableApps: LO3.3.0-25.8.5.2;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.
Re: Increment by real value using SpinButton/NumericalField
Zizi64 wrote:Put the linked cell onto an another (hidden) sheet, and the result of the dividing onto the main sheet.By readability I mean not too much unnecessary numbers. I am only interested in real number (1.6) and not integer value (16).
I'm not sure I understand you. How is this different from your intial suggestion - to divide the value of the linked cell by 10? Isn't this effectively the same thing, only the sheet is different?
OpenOffice 4.1.4. Windows 10
Re: Increment by real value using SpinButton/NumericalField
If you not needed change the value MANUALLY, then maybe this solution will be appropriate for you: The helper cell is not shown on the main Sheet.I'm not sure I understand you. How is this different from your intial suggestion - to divide the value of the linked cell by 10? Isn't this effectively the same thing, only the sheet is different?
But: if you need to change the non-Integer type number manually too, then you must write simple macro to achieve this task.
For example the macro will divide the value of the spinbutton, and will put the result into the target cell.
And when you want ro modify more than one cell by one Spinbutton (or other Form Control Element) only, then you must use the API functions, and the "oEvent" thing described above.
For example: The macro will modify the value of the actually SELECTED cell. The macro will get the original value of the highlighted cell, and will increase/decrease it by 0.1 . The the macro will put the result value into the cell. In this case you will not use any Cell formula, and you will able modify the value of the cell manually and independently from the Form Control element.
You must study and use the API functions for this task.
Tibor Kovacs, Hungary; LO7.5.8/25.8.5.2 /Win7-10-11 x64Prof.
PortableApps: LO3.3.0-25.8.5.2;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.
PortableApps: LO3.3.0-25.8.5.2;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.
Re: Increment by real value using SpinButton/NumericalField
My proposition:
Use two buttons, group them and assign them macros
As in the attached example. The SpinButton control uses only integers and only in the defined range from MIN to MAX. You can enter a greater (smaller) number than MAX (MIN) in the cell. However, using the button will adjust the value to the next possible one. For example, MAX = 100, 120 entered, the use of the "decrease" button will adjust the value to 99 if the value increase was 1
Use two buttons, group them and assign them macros
As in the attached example. The SpinButton control uses only integers and only in the defined range from MIN to MAX. You can enter a greater (smaller) number than MAX (MIN) in the cell. However, using the button will adjust the value to the next possible one. For example, MAX = 100, 120 entered, the use of the "decrease" button will adjust the value to 99 if the value increase was 1
AOO 4.1.16, LibreOffice 25.8
Windows 11 64 bits
Windows 11 64 bits
Re: Increment by real value using SpinButton/NumericalField
...or if you want to control more than one cells by one macro, and one pairs of buttons:
Code: Select all
REM ***** BASIC *****
Option Explicit
Sub IncDec_the_Selected_Cell_Value(oEvent)
Dim oCaller as object
Dim oDoc as object
Dim oCellRange as object
Dim oCell as object
Dim sName as string
Dim lColNr as long
Dim lRowNr as long
oCaller=oEvent.Source.Model
sName=oCaller.Name
REM Print "You pushed the button named: ", sName
oDoc = ThisComponent
oCellRange = oDoc.getCurrentSelection
oCell = oCellRange.GetCellByPosition(0,0) 'When you have selected more than one cell, the left-upper cell in the selected range will be modified.
lColNr = oCell.CellAddress.Column
lRowNr = oCell.CellAddress.Row
If lColNr <> 0 or lRowNr > 7 then
MsgBox("The selected cell located outside of the acceptable cell range")
Exit sub
else
Select Case sName
Case "Button1"
oCell.Value = oCell.Value + 0.1
Case "Button2"
oCell.Value = oCell.Value - 0.1
Case else
MsgBox("You cilicked on a non acceptable form control element")
Exit sub
End Select
end if
End SubTibor Kovacs, Hungary; LO7.5.8/25.8.5.2 /Win7-10-11 x64Prof.
PortableApps: LO3.3.0-25.8.5.2;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.
PortableApps: LO3.3.0-25.8.5.2;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.