mercredi 20 décembre 2017

Powerpoint VBA Generate Random Number from a set as an Object Shape

I would like to generate random numbers to update in an object shape to be used as different point values. However, I wish to keep the range of numbers to large whole numbers such as 100, 200, 300 etc...

After searching for suitable code, I couldn't find anything that fit my needs so I tried to make a hybrid of two codes. 1. Update Random Number http://ift.tt/2DjOfx6 2. Choose a Random Number from a list http://ift.tt/2p356S0

This is what I came up with but it doesn't work.

    Sub UpdateRandomNumber(oSh As Shape)
    oSh.TextFrame.TextRange.Text = MyNums()
    Dim MyNums() As String
    Dim Inum As Integer
    Dim Ichosen As Integer
    MyNums = Split("100/200/300/400/500/1000/-100/-200/-300", "/")
    Randomize
    Ichosen = Int(Rnd * (UBound(MyNums) + 1))
    Inum = CInt(MyNums(Ichosen))
    oSh Inum
    End Sub

Do I need to add a function? Or did I mess up somewhere else?

Thanks in advance




Aucun commentaire:

Enregistrer un commentaire