Hi,
I've had a play around and added some code to introduce you to some other possibilities, changing colours and fonts, keepng score, calling other routines etc. Sorry I've no time to Comment it properly, but if you step through, I'm sure you can follow what's happening.
MD
Sub Tails()
Range("B1").Formula = "T" 'Set the call
Flip ' Do the flip
End Sub
Sub Heads()
Range("B1").Formula = "H"
Flip
End Sub
Sub Flip()
Dim Success As Boolean
Dim MyFlip As Double
Randomize
MyFlip = Rnd 'Random number between 0 & 1
If MyFlip > 0.5 Then
Range("B2").Formula = "Tails"
Else
Range("B2").Formula = "Heads"
End If
'Compare first letter of Result weith Guess
If Left(Range("B2"), 1) = Range("B1") Then 'Win
With Range("B3:C3")
.Interior.ColorIndex = 6
.Font.Name = "Arial"
.Font.FontStyle = "Bold Italic"
.Font.Size = 14
End With
With Range("B3")
.Formula = "You win !!!"
End With
Success = True 'for keeping score
Else 'Lose
With Range("B3:C3")
.Interior.ColorIndex = 8
.Font.Name = "Arial"
.Font.FontStyle = "Bold"
.Font.Size = 12
End With
With Range("B3")
.Formula = "Sorry, you lose."
End With
Success = False
End If
' Call another routine to keep score
CountScore Success
End Sub
Sub CountScore(Success)
'Set up the cell format
Range("B8").NumberFormat = "0 ""wins"""
Range("B9").NumberFormat = "0 "" losses"""
'Make sure there's a numeric value
If Range("B8") = "" Then Range("B8").Formula = 0
If Range("B9") = "" Then Range("B9").Formula = 0
'Change the score by the result "passed" by the Success parameter
If Success = True Then
Range("B8").Formula = Range("B8") + 1
Else
Range("B9").Formula = Range("B9") + 1
End If
End Sub