Results 1 to 4 of 4

Passing a variable from one Sub to another

Threaded View

  1. #1
    Registered User
    Join Date
    09-09-2014
    Location
    America
    MS-Off Ver
    2010
    Posts
    2

    Passing a variable from one Sub to another

    I'm trying to create in sub 1 a variable called Final which is 4 Random numbers (1-6) Minus the smallest of the 4 Random Numbers in the calculation.
    Then I want to use that number (Final) in another sub. And I want the number generated in the second sub to be a different random number each time and put those numbers in 6 listboxes.
    Sub StatRoll()
        
        Dim Stat1 As Integer
            Stat1 = Int(6 * Rnd + 1)
        Dim Stat2 As Integer
            Stat2 = Int(6 * Rnd + 1)
        Dim Stat3 As Integer
            Stat3 = Int(6 * Rnd + 1)
        Dim Stat4 As Integer
            Stat4 = Int(6 * Rnd + 1)
        Dim Total As Integer
            Total = Stat1 + Stat2 + Stat3 + Stat4
        Dim Min As Integer
            Min = WorksheetFunction.Min(Stat1, Stat2, Stat3, Stat4)
        Dim Final As Integer
            Final = Total - Min
            
    
    
    End Sub
    
    Private Sub Level1UserformRollStatsButton_Click()
        
        
                     'empty Level1UserformStat1List
        Level1UserformStat1List.Clear
          
                     'fill Level1UserformStat1List
        With Level1UserformStat1List
            .AddItem Final
        End With
    End Sub

    Again, I want to fill 6 List Boxes with One number each. The number being a Random number each time consisting of 4 Random numbers minus (1-6) the smallest of the 4.

    Thanks in Advance
    Last edited by Leith Ross; 09-28-2014 at 08:53 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Passing Variable from one sub to another
    By bbmak in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-27-2014, 12:39 PM
  2. passing variable name...
    By zara_toustra in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-18-2013, 01:15 PM
  3. Passing a variable from one sub to another sub
    By NRMDU in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2013, 04:45 PM
  4. passing variable?
    By leroiv in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-06-2008, 10:52 AM
  5. [SOLVED] Passing variable to VarType of other Variable
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-22-2005, 10:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1