Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

VBA-Excel: Arrays – One Dimension, Static Array

An Array is a collection of values under the same name and differentiated using index values.

For creating one dimensional static array, follow the below steps

  • Declare an Array
  • Store values in array
  • Retrieve values from array.

Declare an Array

Dim arrData(5)

Store values in array

arrData(0) = “1”

arrData(1) = “2”

arrData(2) = “3”

Retrieve values from array.

MsgBox arrData(3)

Complete Code:

Function FnStaticSingleArray()

    Dim arrData(5)    
 arrData(0) = "1"
  arrData(1) = "2"
  arrData(2) = "3"  
  arrData(3) = "4"
  arrData(4) = "5"
  arrData(5) = "6"
  MsgBox arrData(5)

  For i = 0 To UBound(arrData)

        arrData(i) = i + 1


  MsgBox arrData(3)  

End Function


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: