none
selected numbers generator RRS feed

  • General discussion

  • hi

    I need some code that would allow me to generate at random the numbers 25,50,75,100 every time i clicked the button. I will need to assign this to a shape and not pop up in a message box, (i found something that would let a message pop up and id want the number in the shape)

    i don't normally use VBA so if you could type it so i could just copy and paste it in to a Project in powerpoint that would be great.

    Thanks

    Thursday, June 30, 2016 7:08 PM

All replies

  • Sub GenerateRandomNumber()
        Dim shp As Shape
        Dim Number As Long
        
        Set shp = ThisWorkbook.Worksheets("Sheet1").Shapes("Rectangle 1")
        Number = 25 * WorksheetFunction.RandBetween(1, 4)
        
        shp.TextFrame.Characters.Text = Number
    End Sub
    


    http://www.ambienteoffice.com.br - http://www.clarian.com.br

    Friday, July 1, 2016 5:46 PM