Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-18-2014, 11:00 PM
excelledsoftware excelledsoftware is offline RandBetween for PowerPoint Windows 7 64bit RandBetween for PowerPoint Office 2003
IT Specialist
RandBetween for PowerPoint
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default RandBetween for PowerPoint

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
Any idea on how to get this work would be very helpful. I know that I can already use the following to accomplish this but I would like to figure out the RandBetween

Code that works
Code:
    TotalProblems = UBound(TestArray) + 1
    z = Int(Rnd() * TotalProblems) + 1
    Debug.Print TestArray(z - 1)
Thanks in advance
Reply With Quote
  #2  
Old 09-19-2014, 11:32 PM
excelledsoftware excelledsoftware is offline RandBetween for PowerPoint Windows 7 64bit RandBetween for PowerPoint Office 2003
IT Specialist
RandBetween for PowerPoint
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

Wow I feel rather silly. I played with the existing code a little bit and this works just fine.

Code:

z = Int(Rnd() * TotalProblems)
If TotalProblems = 3 then the rnd function will put out either 0,1 or 2.

Exactly what I need.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
RandBetween for PowerPoint 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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:46 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft