TOP

VBA Function: Array

Description

The VBA Array function returns an array containing the values passed as arguments.


Array Syntax

Array(value_0, value_1, value_2, etc.)

VBA Array Example

Using the Array function to get an array containing the specified values:

Sub ArrayExample()
    
      'An array consisting of 4 elements
      array = Array("www", "moonexcel", "com", "ua")
    
      'Display elements separately
      MsgBox array(0) 'Returns: www
      MsgBox array(1) 'Returns: moonexcel
      MsgBox array(2) 'Returns: com
      MsgBox array(3) 'Returns: ua
    
      'Display all array elements (separated by ".")
      MsgBox Join(array, ".") 'Returns: www.moonexcel.com.ua
    
End Sub