VBA Array IsArray function

VBA Array IsArray Function in Excel

VBA Array IsArray function checks whether the specified input variable is an array or not. It returns a boolean value. The specified input varaible ia an array then returns True, otherwise returns False. Let us examples in the following tutorial.

Syntax of the VBA IsArray Function

Here is the Syntax of the IsArray Function in Excel VBA.

IsArray(VarName) As Boolean

Where VarName: It is a mandatory argument. The VarName argument represents a variable to be checked.

Example1: VBA IsArray Function in Excel

Let us see the vba macro code to check variable is an array or not. In the following example the specified variable an array variable. So, It returns output as TRUE.

'VBA IsArray Function
Sub VBA_IsArray_Function()

    'Declare an array variable
    Dim sWeekDays As Variant
    
    'Define an Array values
    sWeekDays = Array("North", "East", "West", "South")
    
    'Find Array Upper Bound
    MsgBox "Variable(sWeekDays) is an Array or Not: " & isarray(sWeekDays), vbInformation, "VBAF1"
        
End Sub

Here is the output screenshot of above macro code.

VBA IsArray Function

Example2: VBA IsArray Function in Excel

Here is one more example vba macro code to check variable is an array or not. In the following example the specified variable is not an array variable. So, It returns output as FALSE.

'VBA IsArray Function
Sub VBA_IsArray_Function_Ex()

    'Declare an array variable
    Dim sInput As String
    
    'Define an Array values
    sInput = "VBAF1"
    
    'Find Array Upper Bound
    MsgBox "Variable(sInput) is an Array or Not: " & isarray(sInput), vbInformation, "VBAF1"
                
End Sub

Let us see the output screenshot of above macro code.

VBA IsArray Function

Instructions to use Macro

Here are the instructions to use above macro in Visual basic editor.

  • Open Visual Basic Editor(VBE) by clicking Alt +F11
  • Go to code window by clicking F7
  • Copy above specified macro or procedure
  • Paste above copied code in code window
  • Run macro by clicking F5 or Run command
  • You can see output on the screen
  • Find above specified output screenshot.

Other related VBA Arrays articles

You may also like the related VBA Array articles.

Back to VBA Arrays




Leave a Comment

Your email address will not be published. Required fields are marked *