Bob? Code to Post?

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

Thanks Bob!

Could you put the code in a reply to this message!

Also what does

Dim cellvalue

do?

Thanks
Nick
 
This is my entire module reposted. Should work, as far as I can tell.
It's reporting the correct values on lose. (What was happening, was,
when it would put down the "Lose", the value of B2 would recalculate,
and no longer be 7.)

And FYI, Dim cellvalue defines 'cellvalue' as a variable which I can
pass data to. I use it to define what cell is currently being used.

START OF MODULE (Insert New Module, Paste from the top)

Dim cellvalue

Sub Craps()
'Excel Craps V1.1
Setup:
Application.ScreenUpdating = True
[B5] = [B2]

Rollem:
If (([B5] = 2) Or ([B5] = 3) Or ([B5] = 12)) Then GoTo CrapOut
If (([B5] = 7) Or ([B5] = 11)) Then GoTo FirstLucky
cellvalue = 0
GoTo NotWinner
End

NotWinner:
Application.ScreenUpdating = True
Application.Calculate
Repeater:
cellvalue = cellvalue + 1
If ([B2] = "7") Then GoTo SevenLose
Worksheets("Sheet1").Cells(cellvalue + 5, 2).Value = [Sheet1!B2]
If ([B2] = [B5]) Then GoTo Winner
GoTo LoopAround
End

LoopAround:
GoTo Repeater
End

Winner:
Worksheets("Sheet1").Cells(cellvalue + 5, 2).Value = [B2]
Worksheets("Sheet1").Cells(cellvalue + 5, 3).Value = "Win"
Beep
Beep
Beep
Application.ScreenUpdating = True
End

SevenLose:
Worksheets("Sheet1").Cells(cellvalue + 5, 2).Value = "7"
Worksheets("Sheet1").Cells(cellvalue + 5, 3).Value = "Lose"
Application.ScreenUpdating = True
End

FirstLucky:
[C5] = "Win"
Beep
Beep
Beep
End

CrapOut:
[C5] = "Lose"

End Sub

END OF MODULE

Might be back on the forums / NG later in the day. Got presentations to
prepare before lunch.

Hope it helps.

-Bob
 
Hi Bob

Had to rename some of the coding because it was in there
twice, eg. >SevenLose: to >SevenLoseAgain:

Otherwise all OK!

Still don't really get Dim cellvalue

Thanks tho
Nick
 
Back
Top