VBA IsArray 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 a specified variable or expression is an array or not. It has one input parameter. VBA IsArray function in Excel returns a Boolean value (True or False). If specified variant is an array then it returns True, Otherwise it returns False.
We can’t use this function as a worksheet function. We can only use as a VBA function. This function can be used in either procedure or function in a VBA editor window in Excel. We can use this VBA IsArray 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 IsArray function, where we can use this VBA IsArray function and real-time examples.
- Overview
- Syntax of VBA IsArray Function
- Parameters or Arguments
- Where we can apply or use VBA IsArray Function?
- Example 1: Check an expression(“VBAF1”) is an array or not
- Example 2: Check an expression(12345) is an array or not
- Example 3: Check an expression(aCnt()) is an array or not
- Example 4: Check an expression(acnt(5)) is an array or not
- Instructions to Run VBA Macro Code
- Other Useful Resources
Syntax of VBA IsArray Function
The syntax of the VBA IsArray function is
IsArray(VarName)
The VBA IsArray function returns a boolean value either True or False.
Parameters or Arguments
The IsArray function has one input parameter or argument.
Where
VarName: It is a required parameter. The VarName that you want to evaluate.
Where we can apply or use VBA IsArray Function?
We can use this VBA IsArray 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(“VBAF1”) is an array or not
Here is a simple example of the VBA IsArray function. This below example checks the specified string(VBAF1) is an array or not. The output of below macro is FALSE.
'Check an expression("VBAF1") is an array or not Sub VBA_IsArray_Function_Ex1() 'Variable declaration Dim iExpression As String Dim sOutput As Boolean iExpression = "VBAF1" sOutput = IsArray(iExpression) 'Display output message MsgBox "The expression('VBAF1') is an array or not : " & sOutput, vbInformation, "VBA IsArray Function" End Sub
Output: Here is the screen shot of the first example output.
Example 2: Check an expression(12345) is an array or not
Here is another example of the VBA IsArray function. This below example checks the specified number(12345) is an array or not. The output of below macro is FALSE.
'Check an expression(12345) is an array or not Sub VBA_IsArray_Function_Ex2() 'Variable declaration Dim iExpression As Integer Dim sOutput As Boolean iExpression = 12345 sOutput = IsArray(iExpression) 'Display output message MsgBox "The expression(12345) is an array or not : " & sOutput, vbInformation, "VBA IsArray Function" End Sub
Output: Here is the screen shot of the second example output.
Example 3: Check an expression(aCnt()) is an array or not
Here is a simple example of the VBA IsArray function. This below example checks the specified variable(aCnt()) is an array or not. The output of below macro returns TRUE.
'Check an expression(aCnt()) is an array or not Sub VBA_IsArray_Function_Ex3() 'Variable declaration Dim aCnt() As Variant Dim sOutput As Boolean sOutput = IsArray(aCnt) 'Display output message MsgBox "The expression(aCnt()) is an array or not : " & sOutput, vbInformation, "VBA IsArray Function" End Sub
Output:Here is the screen shot of the third example output.
Example 4: Check an expression(acnt(5)) is an array or not
Here is a simple example of the VBA IsArray function. This below example checks the specified variable(aCnt(5)) is date or not. The output of below macro is TRUE.
'Check an expression(acnt(5)) is an array or not Sub VBA_IsArray_Function_Ex4() 'Variable declaration Dim aCnt As Variant Dim sOutput As Boolean aCnt = Array(1, 2, 3, 4, 5) sOutput = IsArray(aCnt) 'Display output message MsgBox "The expression(aCnt(5)) is an array or not : " & sOutput, vbInformation, "VBA IsArray Function" End Sub
Output: Here is the screen shot of the fourth 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