VBA Function: IsNumeric

The VBA IsNumeric function returns True if the value is a number (or can be considered as a number) or False if it is not.

Usage:

IsNumeric(value)


Example of Usage

Using the IsNumeric function to check if the value entered by the user can be considered as a number:

Sub example()

    number = InputBox("Enter a number:")
    
    'Check the entered value
    If IsNumeric(number) Then
    
        'Action to perform if the entered value is a number
        MsgBox "Congratulations, great effort!"
    
    End If

End Sub

Example of Values

Using the IsNumeric function to determine if the following different values can be considered as numbers:

Sub example()
    
    MsgBox IsNumeric(0) 'Returns: True
    MsgBox IsNumeric("0") 'Returns: True
    MsgBox IsNumeric(1) 'Returns: True
    MsgBox IsNumeric("1") 'Returns: True
    MsgBox IsNumeric(" 1 ") 'Returns: True
    MsgBox IsNumeric(-45) 'Returns: True
    MsgBox IsNumeric("45") 'Returns: True
    MsgBox IsNumeric("-45") 'Returns: True
    MsgBox IsNumeric(36.21) 'Returns: True
    MsgBox IsNumeric("-36.21") 'Returns: True
    MsgBox IsNumeric(3 + "2") 'Returns: True
    MsgBox IsNumeric(True) 'Returns: True
    MsgBox IsNumeric(False) 'Returns: True
    
    MsgBox IsNumeric("3b") 'Returns: False
    MsgBox IsNumeric("one") 'Returns: False
    MsgBox IsNumeric("") 'Returns: False
    MsgBox IsNumeric(Null) 'Returns: False

End Sub