Be the first user to complete this post

  • 0
Add to List

VBA-Excel: Create Array using Array() Function

Description:

You can create an array using Array() function. You need to provide all the elements which you want in an array inside Array() and store it in a variable and that variable will be converted into array.

Format:

Array(Element1, Element2, Element3…..ElementN)

Arguments:

  • Elements
    • Manda­tory
    • Type: Any Data Type


Example:

Function FnArrayFunction()

    Dim arrA As Variant

  Dim strString

  arrA = Array("1", "5", "8", "10")

  For i = LBound(arrA) To UBound(arrA)

      strString = strString & " " & arrA(i) & vbCrLf

  Next

  MsgBox strString

End Function
Array Function
Array Function 



Also Read:

  1. VBA-Excel: Array Functions – LBound and UBound()
  2. VBA-Excel: Date-Time Functions – DateValue()
  3. VBA-Excel: Date-Time Functions - Timer()
  4. VBA-Excel: Array Functions – Split()
  5. VBA-Excel: Date-Time Functions – IsDate()
  6. VBA-Excel: Date-Time Functions – DateSerial()
  7. VBA-Excel: Get all the WeekDays or Working days in Specified Date Range, (excluding Satudays and Sundays)
  8. VBA-Excel: Array Functions – IsArray()