## [Solved]Trying to move the results of a RAND function

### [Solved]Trying to move the results of a RAND function

I have a formula for creating a random number in a cell. Now i would like to execute the formula each time so when it calculates the random number i can have it show up in a stand alone cell. The reason i want to do this is because each time i calculate it or execute the command i will see a different number between 1 and 30. I then want to be able to create a new command such as IF that will say, "if g 25 = 24, "Double" or "if g25 = 7, "Ground out" Any help is greatly appreciated. Thanks
Last edited by Brevardo on Tue Jul 23, 2019 3:18 am, edited 1 time in total.
Open Office 3.1
Brevardo

Posts: 15
Joined: Sat Jul 20, 2019 12:58 pm

### Re: Trying to move the results of a RAND function from the c

Now i would like to execute the formula each time so when it calculates the random number i can have it show up in a stand alone cell.

You can not COPY a value by a FORMULA. A formula will REFERENCE the value.
Copy it manually or write a macro for this task.

I then want to be able to create a new command such as IF that will say, "if g 25 = 24, "Double" or "if g25 = 7, "Ground out"

Code: Select all   Expand viewCollapse view
`=IF(G25=24;"Double";"")`

Code: Select all   Expand viewCollapse view
`=IF(G25=7;"Ground out";"")`

And you can use combined (nested) the IF statements too.
Code: Select all   Expand viewCollapse view
`=IF(G25=24;"Double";IF(G25=7;"Ground out";""))`
Tibor Kovacs, Hungary; LO6.1.6 on Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-6.3.3; AOO4.1.6
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.

Zizi64
Volunteer

Posts: 8546
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

### Re: Trying to move the results of a RAND function from the c

Okay. This is good info. If i do the nested example you provided, can i have 4 or 5 "If" commands? The only thing that confused me was the parentheses. How many would I need to have in the formula if say I use 5 "If" commands? Thanks
Open Office 3.1
Brevardo

Posts: 15
Joined: Sat Jul 20, 2019 12:58 pm

### Re: Trying to move the results of a RAND function from the c

If i do the nested example you provided, can i have 4 or 5 "If" commands?

Yes you can. See the Help.
Code: Select all   Expand viewCollapse view
`=IF(The Condition;Output when it is True;Output when it is False)`

You can insert a new IF() into the output places of a formula.

But it is better to use a helper table and the function VLOOKUP() instead of the nested IF() - when you want to use more than 3-4 conditions for same input parameter.
Tibor Kovacs, Hungary; LO6.1.6 on Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-6.3.3; AOO4.1.6
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.

Zizi64
Volunteer

Posts: 8546
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

### Re: Trying to move the results of a RAND function from the c

Okay. That makes sense. Let me go ahead and try that and Ill keep you posted. Thanks again
Open Office 3.1
Brevardo

Posts: 15
Joined: Sat Jul 20, 2019 12:58 pm

### Re: Trying to move the results of a RAND function from the c

If you have a lot of conditions that you want to have specific messages for, then using a table and the VLOOKUP function, as I now see Tibor already suggested.
The table option would also allow quick changes, additions and deletions if the messages and/or number of messages changed.
OpenOffice 4.1.7 and LibreOffice 6.3.3.2 on Windows 7 Pro & Ultimate
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.

RusselB
Moderator

Posts: 5689
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

### Re: Trying to move the results of a RAND function from the c

Brevardo wrote:I then want to be able to create a new command such as IF that will say, "if g 25 = 24, "Double" or "if g25 = 7, "Ground out"

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.

Brevardo wrote:Any help is greatly appreciated.
[Tutorial] Ten concepts that every Calc user should know
Mr. Programmer
AOO 4.1.7 Build 9800 on MacOS 10.14.6.   The locale for any menus or Calc formulas in my posts is English (USA).

MrProgrammer
Moderator

Posts: 3898
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA