PGSystemTester

Shuffled Deck of Cards VBA

Aug 2nd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Creates a random array of integers 1 to 52 (for a deck of cards)
  2. Sub shuffleTheDeckArray()
  3. Dim bigNumberArray(51) As Double, cardDeck(51) As Long, i As Long
  4.  
  5. For i = 0 To 51
  6.     bigNumberArray(i) = Application.WorksheetFunction.RandBetween(0, 9999999999999#)
  7. Next i
  8.  
  9. For i = 0 To 51
  10.     cardDeck(i) = Application.WorksheetFunction.Match(Application.WorksheetFunction.Large(bigNumberArray, 1 + i), bigNumberArray, 0)
  11.     Debug.Print cardDeck(i)
  12. Next i
  13.  
  14. Erase bigNumberArray 'no longer needed, erased for memory
  15.  
  16. End Sub
Add Comment
Please, Sign In to add comment