Using Isnumeric and Isnumber in VBA

Associated Files Download Links

This article will teach you how to use the IsNumeric and IsNumber functions in VBA to check if values are numbers.

IsNumeric is a built-in VBA function, while IsNumber is an Excel function which can be called from VBA code.

 

Using IsNumeric in VBA

IsNumeric is the VBA function which checks if a value is numeric and returns a Boolean TRUE or FALSE as a result.

The function can take a variable or a cell value. Here is the example:

In this example, we check if the value from the cell A1 is numeric using the IsNumeric. This function returns the appropriate message, depending on the result of the function.

 

Using IsNumber in VBA

IsNumber is the Excel function, which can be used in VBA also and has an almost similar output as IsNumeric. Let’s look at the example of the IsNumber function:

As you can see from the code, the difference is in the syntax when calling the function. Since IsNumber is the Excel function, we need to put Application.WorksheetFunction before the function call. The result of the function is the same in most cases.

 

Difference between IsNumber and IsNumeric in VBA

IsNumber checks if a value is stored as a number. On the other side, IsNumeric checks if a value can be converted into a number. This is the main difference between the two functions.

For example, if you pass a blank cell as a parameter, IsNumber will return FALSE, while IsNumeric will return TRUE. Also, if you pass a cell containing number stored as a text IsNumber will return FALSE and IsNumeric TRUE.

You need to pay attention to these limitations of both functions and decide in which cases is better to use IsNumeric and when IsNumber.

You may also like some of this related content...