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