![]() |
|
#1
|
|||
|
|||
|
I am making a powerpoint that presents the user with a problem from an array list. I want to be able to pull a random problem from the array and I like the RandBetween Function in Excel. I know there are otherways to do this but the RandBetween is so simple. How can I make the following work?
Code:
Sub PullRandom()
Dim TestArray as Variant, RandNum as integer, xls as object
TestArray = Array("1+1","2+2","3+3")
set xls = createobject("Excel.application")
RandNum = xls.worksheetfunction.RandBetween(lbound(TestArray), ubound(TestArray))
debug.print RandNum
End Sub
Code that works Code:
TotalProblems = UBound(TestArray) + 1
z = Int(Rnd() * TotalProblems) + 1
Debug.Print TestArray(z - 1)
|
|
#2
|
|||
|
|||
|
Wow I feel rather silly. I played with the existing code a little bit and this works just fine.
Code:
z = Int(Rnd() * TotalProblems) Exactly what I need. |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
RandBetween Formula Help
|
acbh | Excel | 1 | 09-12-2013 06:51 PM |
| PowerPoint 2007 --> PowerPoint 2003 Webpage? | josephsh | PowerPoint | 0 | 06-09-2011 11:22 PM |