Call

Excel IsArray Function: Determine if a Variable is an Array


The IsArrayExcel Function is used to determine whether or not a variable is an array or not. The IsArrayExcel Function returns a Boolean value during the evaluation.

The Basics:

 

True/False = IsArray(ValueToEvaluate)

Now. let us look at an example. We are going to create two variables, one a string value and one a string array. Our code will generate a message upon the successful identification of the array value.

Code

Dim StringArray(3) As String

 Dim StringValue As String

 StringValue = “Test Value”

 StringArray(1) = “Test Value”

 If IsArray(StringValue) Then MsgBox “The variable StringValue is the Array value”

 If IsArray(StringArray) Then MsgBox “The variable StringArray is the Array value”

Output

Code

 ‘Declare variables

 Dim StringToProcess As String’Variable string to process

 Dim arrValues() As String’String Array

 Dim A, B As Long’Value to use as a counter

 Dim tmpValue As Variant

 Dim Check As Boolean

 StringToProcess = ActiveSheet.Cells(2, 1).Value ‘Assign the information to process to our variable

 arrValues() = Split(StringToProcess, ” “) ‘Parse the string into a string array using a space delimiter

 Counter = 5

For A = LBound(arrValues) To UBound(arrValues)

 Check = IsNumeric(arrValues(A))

If Check Then

ActiveSheet.Cells(Counter, 1).Value = CDbl(arrValues(A))

Counter = Counter + 1

End If

 

Next Output