Uses a Resume statement after an error occurs:
Sub EnterSquareRoot6()
Dim Num As Variant
Dim Msg As String
Dim Ans As Integer
TryAgain:
On Error GoTo BadEntry
Num = InputBox("Enter a value")
If Num = "" Then Exit Sub
ActiveCell.value = Sqr(Num)
Exit Sub
BadEntry:
Msg = "An error occurred. Try again?"
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbYes Then Resume TryAgain
End Sub
Related examples in the same category