I'm trying to write code that will generate 4 random poker hands
(source: wiseowl.co.uk)
The values should be, obviously, unique. Here's the code that I have tried already, however I can't make it work.
Sub poker_is_hard()
Dim r As Range
Dim c As Variant
Dim s As Variant
Dim cs As Variant
Set r = Workbooks("Poker game.xls").Worksheets("Cards").Range("B2:E6")
cs = c & "" & s
For Each cs In r
c = Int(Math.Rnd * 13) + 1
'Card's value
If c = 11 Then
c = "J"
ElseIf c = 12 Then
c = "Q"
ElseIf c = 13 Then
c = "K"
ElseIf c = 1 Then
c = "A"
Else
End If
'Card's symbol
s = Int(Math.Rnd * 4) + 1
If s = 1 Then
s = ThisWorkbook.Worksheets("Symbols").Range("B1").Value
ElseIf s = 2 Then
s = ThisWorkbook.Worksheets("Symbols").Range("B2").Value
ElseIf s = 3 Then
s = ThisWorkbook.Worksheets("Symbols").Range("B3").Value
Else
s = ThisWorkbook.Worksheets("Symbols").Range("B4").Value
End If
Next cs
End Sub