Sub GetPassword() Dim PassWord As String, i As Integer i = 0 Do i = i + 1 If i > 3 Then MsgBox "Sorry, Only three tries" Exit Sub End If PassWord = InputBox("Enter Password") Loop Until PassWord = "XXX" MsgBox "Welcome" End Sub