Objective of VBA IsNumeric Function
VBA IsNumeric function 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 has one 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 can be used 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.
- Objective of VBA IsNumeric Function
- 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 use Macro Codes
Syntax of VBA IsNumeric Function
The syntax of the VBA IsNumeric function is
IsNumeric(Expression)
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 use Macro Codes
Here are the step by step instructions to use the VBA IsNumeric function in Excel VBA.
- Open an Excel workbook.
- Press Alt+F11 to open VBA Editor window.
- Go to Insert menu and click on module from the available options.
- Copy above specified macros to the VBA editor.
- Select any procedure from above codes and click on ‘Run’ command or use Keyboard shortcut ‘F5’.
List of VBA Functions:
Please click on below link to go back to see all List of VBA Functions.