PDA

View Full Version : Number generator



ian87
06-30-2016, 02:37 PM
Hi guys,

I really need some help. I need to generate the numbers 25,50,75,100 at random and to be visible on the shape its linked too or in other words I don't want a message box to appear with it. I have no prior knowledge of VBA but have managed to get this working for generating numbers between 1-10 and 1-999 (from coding on the internet) but when it comes to generating select numbers I can not find a code to do it. if anyone could write the code for me this would be fantastic.

thanks

John Wilson
07-02-2016, 02:34 AM
This assumes you are clicking on the target shape in show Mode

Give the shape an actio of Run Macro


Sub shapeNum(oshp As Shape)Dim rayNum(1 To 4) As Integer
Dim rndChoice As Integer
rayNum(1) = 25
rayNum(2) = 50
rayNum(3) = 75
rayNum(4) = 100
Randomize
rndChoice = Int(Rnd * 4) + 1
Debug.Print rndChoice
oshp.TextFrame.TextRange = CStr(rayNum(rndChoice))
End Sub