Discussion:
Random number
(too old to reply)
Alec Stonehouse
2004-05-18 18:25:37 UTC
Permalink
HI Group,

I want PPT to generate a random number (between 1 and 20) on a buton click.
I have never tried using VBA and suspect this is the only way to do it.
If a kind person has any ideas and lots of patience, I would love to hear
from you.

thanks in advance

Alec
Alec Stonehouse
2004-05-18 18:36:10 UTC
Permalink
I should have mentioned I am using ppt xp on win xp. - ta
Post by Alec Stonehouse
HI Group,
I want PPT to generate a random number (between 1 and 20) on a buton click.
I have never tried using VBA and suspect this is the only way to do it.
If a kind person has any ideas and lots of patience, I would love to hear
from you.
thanks in advance
Alec
PDEkman
2004-05-18 19:41:03 UTC
Permalink
I'd just link to excel and use it's random number generato
e.g put "=RANDBETWEEN(1,20)" in a cell, and then hit F
a few times
Just use autoshape to create the button
Rightclick the button and select hyperlink/to other file/ an
select the name of your excel file
2 problems here
1) the excel file will look lousy compared to the powerpoint fil
But you can spend some time formating and sizing it to your need
(and then save it.
2) You'll get the same series of "random numbers" every tim
you open the file UNLESS you save the results. So unless you sav
your audience will start thinking that the numbers are not very random
Probably almost all random number generators you might run int
would have the same problem though.
Alec Stonehouse
2004-05-18 20:38:17 UTC
Permalink
The random number generator in excel works fairly well.
I dont get the 'randbetween' option, only 'rand'.
However, it does seem to give a unique number each time you run it.

It would be much better if I could get ppt to do it.
Any more thoughts????
I'd just link to excel and use it's random number generator
e.g put "=RANDBETWEEN(1,20)" in a cell, and then hit F9
a few times.
Just use autoshape to create the button.
Rightclick the button and select hyperlink/to other file/ and
select the name of your excel file.
2 problems here.
1) the excel file will look lousy compared to the powerpoint file
But you can spend some time formating and sizing it to your needs
(and then save it.)
2) You'll get the same series of "random numbers" every time
you open the file UNLESS you save the results. So unless you save
your audience will start thinking that the numbers are not very random.
Probably almost all random number generators you might run into
would have the same problem though.
Steve Rindsberg
2004-05-18 23:51:55 UTC
Permalink
Post by Alec Stonehouse
HI Group,
I want PPT to generate a random number (between 1 and 20) on a buton click.
I have never tried using VBA and suspect this is the only way to do it.
If a kind person has any ideas and lots of patience, I would love to hear
from you.
Sub MakeARandomNumber()

Dim MaxNumber As Long

' Edit this to be the highest number you're willing to accept
MaxNumber = 42

Randomize ' Initialize random-number generator.
MsgBox (Int(MaxNumber * Rnd) + 1)

End Sub

That's the code. Have a read here to learn ... er ... where to stick it. ;-)

How do I USE this VBA stuff in PowerPoint?
http://www.rdpslides.com/pptfaq/FAQ00033.htm

--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
David M. Marcovitz
2004-05-19 00:26:03 UTC
Permalink
Check out Examples 8.13 through 8.17 on my web site

http://www.loyola.edu/education/PowerfulPowerPoint

Click on Examples by Chapter and click on Chapter 8 to find the examples. These examples use random numbers in VBA in a variety of ways

--Davi

David M. Marcovit
Author of _Powerful PowerPoint for Educators
http://www.loyola.edu/education/PowerfulPowerPoint
Alec Stonehouse
2004-05-19 17:25:48 UTC
Permalink
Thanking you all. I am on a big journey I think.
http://www.loyola.edu/education/PowerfulPowerPoint/
Click on Examples by Chapter and click on Chapter 8 to find the examples.
These examples use random numbers in VBA in a variety of ways.
--David
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
Loading...