Dim leNombre As Integer
Dim nbCoups As Integer

Private Sub CommandButton1_Click()
    Randomize
    leNombre = Int((Rnd * 100) + 1)
    nbCoups = 0
    Columns("A:A").Select
    Selection.ClearContents
End Sub

Private Sub CommandButton2_Click()
    nbCoups = nbCoups + 1
    Cells(nbCoups, 1) = TextBox1.Value
    ' MsgBox TextBox1.Value & " | " & leNombre
    If TextBox1.Value > leNombre Then
        MsgBox "Le nombre secret est plus petit"
    ElseIf TextBox1.Value < leNombre Then
        MsgBox "Le nombre secret est plus grand"
    Else
        MsgBox "Bravo ! Gagné en " & nbCoups & " coups."
    End If
End Sub
