chuckles1066
Banned
- Joined
- Dec 20, 2004
- Messages
- 372
This works but I'm sure it's unnecessarily bloated.
Also, it terminates with a "Return without GoSub" error which isn't important because the 65535 passes have completed but it's annoying.
Also, it terminates with a "Return without GoSub" error which isn't important because the 65535 passes have completed but it's annoying.
Code:
Sub RollDice()
Dim Dice1, Dice2 As Integer
Dim rollcount As Long
Randomize
Application.ScreenUpdating = False
For rollcount = 1 To 65535
Dice1 = Int(Rnd() * 6) + 1
Dice2 = Int(Rnd() * 6) + 1
Select Case Dice1
Case 1
GoSub d11
Case 2
GoSub d12
Case 3
GoSub d13
Case 4
GoSub d14
Case 5
GoSub d15
Case 6
GoSub d16
End Select
Next
d11:
Select Case Dice2
Case 1
Cells(1, 2).Value = Cells(1, 2).Value + 1
Case 2
Cells(2, 2).Value = Cells(2, 2).Value + 1
Case 3
Cells(3, 2).Value = Cells(3, 2).Value + 1
Case 4
Cells(4, 2).Value = Cells(4, 2).Value + 1
Case 5
Cells(5, 2).Value = Cells(5, 2).Value + 1
Case 6
Cells(6, 2).Value = Cells(6, 2).Value + 1
End Select
Return
d12:
Select Case Dice2
Case 1
Cells(2, 2).Value = Cells(2, 2).Value + 1
Case 2
Cells(7, 2).Value = Cells(7, 2).Value + 1
Case 3
Cells(8, 2).Value = Cells(8, 2).Value + 1
Case 4
Cells(9, 2).Value = Cells(9, 2).Value + 1
Case 5
Cells(10, 2).Value = Cells(10, 2).Value + 1
Case 6
Cells(11, 2).Value = Cells(11, 2).Value + 1
End Select
Return
d13:
Select Case Dice2
Case 1
Cells(3, 2).Value = Cells(3, 2).Value + 1
Case 2
Cells(8, 2).Value = Cells(8, 2).Value + 1
Case 3
Cells(12, 2).Value = Cells(12, 2).Value + 1
Case 4
Cells(13, 2).Value = Cells(13, 2).Value + 1
Case 5
Cells(14, 2).Value = Cells(14, 2).Value + 1
Case 6
Cells(15, 2).Value = Cells(15, 2).Value + 1
End Select
Return
d14:
Select Case Dice2
Case 1
Cells(4, 2).Value = Cells(4, 2).Value + 1
Case 2
Cells(9, 2).Value = Cells(9, 2).Value + 1
Case 3
Cells(13, 2).Value = Cells(13, 2).Value + 1
Case 4
Cells(16, 2).Value = Cells(16, 2).Value + 1
Case 5
Cells(17, 2).Value = Cells(17, 2).Value + 1
Case 6
Cells(18, 2).Value = Cells(18, 2).Value + 1
End Select
Return
d15:
Select Case Dice2
Case 1
Cells(5, 2).Value = Cells(5, 2).Value + 1
Case 2
Cells(10, 2).Value = Cells(10, 2).Value + 1
Case 3
Cells(14, 2).Value = Cells(14, 2).Value + 1
Case 4
Cells(17, 2).Value = Cells(17, 2).Value + 1
Case 5
Cells(19, 2).Value = Cells(19, 2).Value + 1
Case 6
Cells(20, 2).Value = Cells(20, 2).Value + 1
End Select
Return
d16:
Select Case Dice2
Case 1
Cells(6, 2).Value = Cells(6, 2).Value + 1
Case 2
Cells(11, 2).Value = Cells(11, 2).Value + 1
Case 3
Cells(15, 2).Value = Cells(15, 2).Value + 1
Case 4
Cells(18, 2).Value = Cells(18, 2).Value + 1
Case 5
Cells(20, 2).Value = Cells(20, 2).Value + 1
Case 6
Cells(21, 2).Value = Cells(21, 2).Value + 1
End Select
Return
End Sub