IsNumber in VBA: How to Check If a Value Is Numeric

VBA & macros · Updated November 23, 2026

Yes, VBA has an IsNumeric function that returns True if a value can be interpreted as a number, and False otherwise. It is the standard way to check for numeric values in VBA code, but it has important quirks you need to understand—for example, it returns True for empty strings and for values that Excel would store as text but can be coerced to a number.

What IsNumeric Actually Does

IsNumeric(expression) is a built-in VBA function that evaluates whether the expression can be converted to a numeric data type (Byte, Integer, Long, Single, Double, Currency, or Decimal). It does not check whether a cell contains a number in Excel’s sense; it checks whether the value could be treated as a number in VBA.

Key behaviors:

  • IsNumeric(123) returns True.
  • IsNumeric("123") returns True because the string can be converted.
  • IsNumeric("12.5") returns True.
  • IsNumeric("1,000") returns True on systems where the comma is the thousands separator (US locale), but False in locales where the comma is the decimal separator.
  • IsNumeric("") returns True—an empty string is treated as 0.
  • IsNumeric("abc") returns False.
  • IsNumeric(True) returns True because Boolean True converts to -1.
  • IsNumeric(#2025-01-01#) returns True because dates are stored as numbers in VBA.

This last point surprises many: a Date value is numeric under the hood, so IsNumeric returns True for dates. If you need to exclude dates, you must add an extra check.

How to Use IsNumeric in a Macro

The typical usage is inside an If statement to validate user input or cell values before performing arithmetic.

Sub CheckValue()
    Dim cellValue As Variant
    cellValue = Range("A1").Value
    
    If IsNumeric(cellValue) Then
        MsgBox "It's a number: " & cellValue * 2
    Else
        MsgBox "Not numeric."
    End If
End Sub

Remember: macros cannot be undone with Ctrl+Z, so always save a copy of your workbook before running any VBA code.

Common Pitfalls and Misconceptions

The biggest misconception is that IsNumeric tells you whether a cell is formatted as a number. It does not. A cell containing the text "123" (with an apostrophe prefix or text formatting) still returns True because the string can be converted. Conversely, a cell containing a number formatted as text with a leading zero, like "00123", returns True as well.

Another common trap: IsNumeric returns True for Empty variables and for Null? Actually, IsNumeric(Null) returns False, but IsNumeric(Empty) returns True because Empty is treated as 0. This can cause unexpected behavior when reading empty cells—an empty cell has a Value of Empty, so IsNumeric(Range("A1").Value) returns True even though the cell is blank.

To avoid this, many developers add an explicit check for empty or blank cells:

If Not IsEmpty(cellValue) And IsNumeric(cellValue) Then
    ' proceed
End If

Also note that IsNumeric depends on the system’s regional settings. A string like "1,5" is numeric in Germany but not in the US. If you need a locale-independent check, you can use VarType or the TypeName function.

Alternatives: VarType, TypeName, and WorksheetFunction.IsNumber

If you want to check whether a cell actually contains a number (not a numeric string), you have a few options:

  • VarType(value) returns vbDouble (5) or vbLong (3) for numbers, vbString (8) for text, vbDate (7) for dates. Example: If VarType(cellValue) = vbDouble Then.
  • TypeName(value) returns the name of the data type, e.g., “Double”, “String”, “Date”. Example: If TypeName(cellValue) = "Double" Then.
  • Excel’s WorksheetFunction.IsNumber checks the actual cell content and returns True only for numbers, not for numeric text. However, it requires a Range reference and cannot be used on a VBA variable directly. Example: If Application.WorksheetFunction.IsNumber(Range("A1")) Then.

For most validation purposes, IsNumeric is sufficient, but if you must distinguish between a number and a numeric string, use VarType or TypeName.

How to Handle Dates and Booleans

Because dates and booleans are numeric in VBA, IsNumeric returns True for them. If you want to exclude them, add checks:

Function IsRealNumber(v As Variant) As Boolean
    If IsEmpty(v) Then Exit Function
    If VarType(v) = vbBoolean Then Exit Function
    If VarType(v) = vbDate Then Exit Function
    IsRealNumber = IsNumeric(v)
End Function

This custom function returns True only for numbers and numeric strings, excluding empty, Boolean, and Date values.

Practical Example: Validating User Input

Suppose you have an input box where the user enters a quantity. You can use IsNumeric to ensure the input is a number before using it in a calculation.

Sub GetQuantity()
    Dim userInput As String
    Dim qty As Double
    
    userInput = InputBox("Enter quantity:")
    If IsNumeric(userInput) Then
        qty = CDbl(userInput)
        MsgBox "You entered " & qty
    Else
        MsgBox "Invalid number."
    End If
End Sub

This works because InputBox returns a string, and IsNumeric checks if that string can be converted to a number.

Frequently Asked Questions

Does IsNumeric work with empty cells? Yes, it returns True for an empty cell because the cell’s Value is Empty, which VBA treats as 0. To avoid this, check IsEmpty first.

Why does IsNumeric return True for dates? Because VBA stores dates as floating-point numbers (the integer part is the day, the fraction is the time). So IsNumeric sees a number. If you need to exclude dates, use VarType(v) <> vbDate.

Is there a way to check if a cell contains a number in Excel, not just a numeric string? Yes, use WorksheetFunction.IsNumber on the cell reference. It returns True only if the cell’s value is a number, not text that looks like a number.

Does IsNumeric work with scientific notation? Yes, strings like "1E3" return True because VBA can convert them to a number.

What about negative numbers or currency symbols? Negative numbers like "-5" return True. Currency symbols like "$" are not recognized, so "$5" returns False.

Can I use IsNumeric in Excel formulas? No, IsNumeric is a VBA function. In Excel formulas, use ISNUMBER instead, which works similarly but is designed for worksheet cells.

Summary and Best Practices

Use IsNumeric when you need a quick check that a value can be treated as a number in VBA. For strict validation, combine it with IsEmpty and VarType to exclude blanks, dates, and booleans. Always save your workbook before running macros, and test with a variety of inputs, especially empty cells and text that looks like numbers.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.