NavList:
A Community Devoted to the Preservation and Practice of Celestial Navigation and Other Methods of Traditional Wayfinding
Re: Using Calc.
From: Nicol�s de Hilster
Date: 2009 Jan 19, 12:00 +0100
From: Nicol�s de Hilster
Date: 2009 Jan 19, 12:00 +0100
George Huxtable wrote: > In cell A1, put a zero. In cell B1, put =IF(A1<0.5,0,B1+1) That's it. > > Because of the choices made about iterations, the program will now > recalculate only once, when F9 is pressed. When you do so, B1 becomes zero, > just as you would expect from that IF statement, A1 being less than 0.5. You > can press F9 as often you wish, and nothing changes. > > But now, change A1 to contain 1 (and press enter). Now, you're asking the IF > statement to take the other path, and set B1 to equal B1+1 (a "circular > reference", if ever I saw one). If you hadn't limited the iterations, Excel > would object to the circular reference. But instead, it does nothing until > you press F9, when B1 becomes 1. And each time you press F9, B1 increments > by 1. That's exactly what was wanted. > > However, anyone who can get Calc to do the same thing is a better man than I > am. If you manage it, do tell me how. > I have a spreadsheet where I needed a figure to increase with a certain step by pressing a button. I solved that by inserting several buttons into the spreadsheet and let them call a function whenever I click on them with my mouse (you can trigger on other events as well). The button can be inserted by the following procedure: - Go to View/Toolbars/Form Controls - Click on the "Push Button" icon - Use the right mouse button to draw a button on a cell on the spreadsheet - Rightclick this button to change the label of it (Control/Properties/General Tab/Label) - In the properties dialog go to Events - Click on the button on the same row as "Mouse button pressed" - this opens the "Assign action" dialog - Click on "Macro" - this opens the "Macro Selector" dialog, and this should be used to select the correct macro for the button For each button I made I had a function like this (in this case the button was to increase the contents of cell B7): Sub rotXPlus setCell("B7",1) End Sub Which on itself would call this function: Function setCell(cellRef,sign) Dim oCell oCell = thisComponent.Sheets(0).getCellRangeByName(cellRef) oCell.Value = oCell.Value+getStep*sign End Function getStep is another function that retrieves the step size from the sheet from cell D4: Function getStep As Double Dim theStep Dim oCell oCell = thisComponent.Sheets(0).getCellRangeByName("D4") getStep = oCell.Value End Function Nicol�s --~--~---------~--~----~------------~-------~--~----~ Navigation List archive: www.fer3.com/arc To post, email NavList@fer3.com To , email NavList-@fer3.com -~----------~----~----~----~------~----~------~--~---