ARRAY

ARRAY(arglist)

Returns an array containing the given values (Variant).


arglistThe comma separated list of values (Array / Variant).

REMARKS
* This can only be used when the array is declared with a Variant data type (As Variant).
* This array is always 0 based.
* This function ignores any Option Base 1 statements.
* If no arguments are given [avValues = Array()], then a zero length array is returned.
* You can use the FILTER function to return an array containing a subset of a string array based on a filter condition.
* You can use the JOIN function to return a text string containing all the elements in an array.
* You can use the SPLIT function to return the array containing a specified number of substrings.
* For the Microsoft documentation refer to learn.microsoft.com

Dim avValues As Variant         'an array declared as a Variant  
avValues = Array(1, 2, 3, 4) 'declares and populates the array
Debug.Print avValues(0) '= 1
Debug.Print avValues(1) '= 2
Debug.Print avValues(2) '= 3
Debug.Print avValues(3) '= 4
Stop 'open Locals window, avValues(4) does not exist

Public Sub MultiDimensional()
Dim arValues As Variant
Dim oItem As Variant
   arValues = Array(Array(1, 2), Array(3, 4), Array(5, 6), Array(7, 8))
   For Each oItem In arValues
      Debug.Print oItem(0)
      Debug.Print oItem(1)
   Next oItem
End Sub

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top