Use IsNumeric to check the input value : IsNumeric « Data Type Functions « VBA / Excel / Access / Word






Use IsNumeric to check the input value

 
Sub EnterSquareRoot3()
    Dim Num As Variant
    Num = InputBox("Enter a value")
    If Not IsNumeric(Num) Then
       MsgBox "You must enter a number."
       Exit Sub
    End If
    If Num < 0 Then
        MsgBox "You must enter a positive number."
        Exit Sub
    End If
    ActiveCell.value = Sqr(Num)
End Sub

 








Related examples in the same category

1.Is the cell numeric