Random Message Box Generator

  • Hi guys!


    Just a little silly one that I can't fathom, be it that I'm tired or just plain stupid :wink:


    All i want is a way, on clicking a button on my userform, where i can bring up a quote randomly picked from a list of quotes and sayings which I will input.




    Any help would be appreciated!!




    Thanks in advance!

  • Re: Random Messagebox Generator


    Hopefully you can expand on this.


    You generate a randon number and the pick the quote.


    [vba]
    Sub x()


    Dim strQuotes(10) As String
    Dim lngIndex As Long

    strQuotes(0) = "A"
    strQuotes(1) = "b"
    strQuotes(2) = "c"
    strQuotes(3) = "d"
    strQuotes(4) = "e"
    strQuotes(5) = "f"
    strQuotes(6) = "g"
    strQuotes(7) = "h"
    strQuotes(8) = "i"
    strQuotes(9) = "j"
    strQuotes(10) = "k"

    lngIndex = Int((10 - 0 + 1) * Rnd + 0)


    MsgBox strQuotes(lngIndex)

    End Sub
    [/vba]
    The quotes can be read from a worksheet, textfile or hard coded.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!