So that first script is no good?  By "macro" did you just mean a formula?

Or do you want the script to enter a number in the first cell, then in each
of the 9 cells below it?

What's a "Christian RPG"?


Jack Ray wrote:
> 
> Terry
> I wasn't real clear, I think
> I have a spreadsheet that calculates starting values for characters in
> a Christian RPG.  There are 10 cells that need a random 2-7 value
> placed one time, on command, then that value maintained in those cells
> until the next time the command keyy is pressed.  They cannot
> recalculate on F9 or opening or anything else that ReCalc seems to do.
>  Each cell is independent of the others, so each value is random.  I
> was actually trying to find something along the old GETKEY function to
> use in an IF statement, but can't get anything to work.
> Jack
> 
> On 4/13/07, TerryJ <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>> Jack Ray wrote:
>> >
>> > I can't figure this out.  I need a Macro that will fill a cell with a
>> > random integral number, between 2 and 7, when a key is hit, not, as
>> > random works normally, whenever the spreadsheet refreshes.
>> > Can anyone show me how?
>> > Jack
>> >
>> >
>>
>> I'm guessing this does what you want.  It just inserts the formula, then
>> converts it to a value.
>>
>> ' * * * * * script follows
>> Sub randValue27
>> 'Inserts a random value between 2 and 7 in the selected cell of a
>> spreadsheet using setFormula
>> 'rather than FunctionAccess.  Set to work ONLY if a single cell is
>> selected.
>> Dim oCell as Object, sFormula as String
>>
>> oCell = ThisComponent.CurrentSelection
>> If NOT oCell.supportsService( "com.sun.star.sheet.SheetCell" ) Then :
>> Exit
>> Sub : End If
>> sFormula = "=RANDBETWEEN(2;7)" : oCell.setFormula( sFormula)
>> oCell.setDataArray( oCell.getDataArray )
>> End Sub
>> ' * * * * * script has ended
>>
>> You could, perhaps more usefully, use script which performs a hard
>> recalculation.
>>
>> ' * * * * * script follows
>> Sub hardRecalc
>> ' Performs a hard recalculation of the spreadsheet - does NOT count as a
>> modification
>> Dim oDoc as Object : oDoc = ThisComponent
>> If NOT oDoc.SupportsService ( "com.sun.star.sheet.SpreadsheetDocument" )
>> Then
>> Exit Sub : End If
>> oDoc.calculateAll()
>> End Sub
>> ' * * * * * script has ended
>>
>> Beware the effects of copying and pasting from an email to the Calc Basic
>> editor.  Your email client may convert single lines to multiple lines.  I
>> can upload a text file if you have problems.
>> --
>> View this message in context:
>> http://www.nabble.com/Macro-question-in-Calc-tf3574343.html#a9989422
>> Sent from the openoffice - users mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> 
> -- 
> Look at the world around you, and you'll see God's creativity;
> Look at the dinner table, and you'll see God's providence;
> Look at the mirror, and you'll see God's sense of humor.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Macro-question-in-Calc-tf3574343.html#a9992875
Sent from the openoffice - users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to