VBA IsNumeric function in Excel is categorized as an Information function in VBA. It is a built-in function in MS Office Excel VBA. This function checks specified Expression is Numeric or not. It has one input parameter. It returns boolean value (True or False).
The IsNumeric function can be used only in VBA. We can’t use this function as a worksheet function. This function use in either procedure or function in a VBA editor window in Excel. We can use this VBA IsNumeric function any number of times in any number of procedures or functions. In the following section we learn what is the syntax and parameters of the IsNumeric function, where we can use this VBA IsNumeric function and real-time examples.
- Overview
- Syntax of VBA IsNumeric Function
- Parameters or Arguments
- Where we can apply or use VBA IsNumeric Function?
- Example 1: Check an expression(100) is numeric or not
- Example 2: Check given expression(100.123) is numeric or not
- Example 3: Check an expression(“ABC”) is numeric or not
- Example 4: Check an expression(“ABC123”) is numeric or not
- Example 5: Check an expression(TRUE) is numeric or not
- Instructions to Run VBA Macro Code
- Other Useful Resources
Syntax of VBA IsNumeric Function
The syntax of the VBA IsNumeric function is
IsNumeric(Expression)
Note: The VBA IsNumeric function returns a boolean value.
Parameters or Arguments
The IsNumeric function has one input parameter or argument.
Where
Expression: It is a required parameter. The Expression that you want to evaluate.
Where we can apply or use VBA IsNumeric Function?
We can use this VBA IsNumeric function in MS Office 365, MS Excel 2016, MS Excel 2013, 2011, Excel 2010, Excel 2007, Excel 2003, Excel 2016 for Mac, Excel 2011 for Mac, Excel Online, Excel for iPhone, Excel for iPad, Excel for Android tablets and Excel for Android Mobiles.
Example 1: Check an expression(100) is numeric or not
Here is a simple example of the VBA IsNumeric function. This below example checks the specified number(100) is numeric or not. The output of below macro is TRUE.
'Check an expression(100) is numeric or not Sub VBA_IsNumeric_Function_Ex1() 'Variable declaration Dim iExpression As Integer Dim sOutput As Boolean iExpression = 100 sOutput = IsNumeric(iExpression) 'Display output message MsgBox "The expression(100) is numeric or not : " & sOutput, vbInformation, "VBA IsNumeric Function" End Sub
Output: Here is the screen shot of the first example output.
Example 2: Check given expression(100.123) is numeric or not
Here is another example of the VBA IsNumeric function. This below example checks the specified number(100.123) is numeric or not. The output of below macro is TRUE.
'Check given expression(100.123) is numeric or not Sub VBA_IsNumeric_Function_Ex2() 'Variable declaration Dim iExpression As Double Dim sOutput As Boolean iExpression = 100.123 sOutput = IsNumeric(iExpression) 'Display output message MsgBox "The expression(100.123) is numeric or not : " & sOutput, vbInformation, "VBA IsNumeric Function" End Sub
Output: Here is the screen shot of the second example output.
Example 3: Check an expression(“ABC”) is numeric or not
Here is a simple example of the VBA IsNumeric function. This below example checks the specified number(“ÄBC”) is numeric or not. The output of below macro returns False.
'Check an expression("ABC") is numeric or not Sub VBA_IsNumeric_Function_Ex3() 'Variable declaration Dim iExpression As String Dim sOutput As Boolean iExpression = "ÄBC" sOutput = IsNumeric(iExpression) 'Display output message MsgBox "The expression('ABC') is numeric or not : " & sOutput, vbInformation, "VBA IsNumeric Function" End Sub
Output:Here is the screen shot of the third example output.
Example 4: Check an expression(“ABC123”) is numeric or not
Here is a simple example of the VBA IsNumeric function. This below example checks the specified number(“ABC123”) is numeric or not. The output of below macro is False.
'Check an expression("ABC123") is numeric or not Sub VBA_IsNumeric_Function_Ex4() 'Variable declaration Dim iExpression As String Dim sOutput As Boolean iExpression = "ÄBC123" sOutput = IsNumeric(iExpression) 'Display output message MsgBox "The expression('ABC123') is numeric or not : " & sOutput, vbInformation, "VBA IsNumeric Function" End Sub
Output: Here is the screen shot of the fourth example output.
Example 5: Check an expression(TRUE) is numeric or not
Here is a simple example of the VBA IsNumeric function.This below example checks the specified number(TRUE) is numeric or not. The output of below macro is TRUE.
'Check an expression(TRUE) is numeric or not Sub VBA_IsNumeric_Function_Ex5() 'Variable declaration Dim iExpression As Boolean Dim sOutput As Boolean iExpression = True sOutput = IsNumeric(iExpression) 'Display output message MsgBox "The expression(TRUE) is numeric or not : " & sOutput, vbInformation, "VBA IsNumeric Function" End Sub
Output: Here is the screen shot of the fifth example output.
Instructions to Run VBA Macro Code or Procedure:
You can refer the following link for the step by step instructions.
Instructions to run VBA Macro Code
Other Useful Resources:
Click on the following links of the useful resources. These helps to learn and gain more knowledge.
VBA Tutorial VBA Functions List VBA Arrays in Excel Blog
VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers