Be the first user to complete this post
|
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
- Mandatory
- 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
Also Read:
- VBA Excel – Looping Through a Range of Cells
- VBA-Excel: Array Functions – Join() – Converts Array to String
- VBA-Excel: Arrays – Two Dimensional, Static Array
- VBA-Excel: Arrays – One Dimension, Dynamic Array
- VBA-Excel : 3D-Ranges - Working with Multiple WorkSheets At The Simultaneously