Using a One-Dimensional Array : Array « Data Type « VBA / Excel / Access / Word






Using a One-Dimensional Array

 
'Option Base 1
Sub FavoriteCities()
    Dim cities(6) As String
    cities(1) = "Baltimore"
    cities(2) = "Atlanta"
    cities(3) = "Boston"
    cities(4) = "Washington"
    cities(5) = "New York"
    cities(6) = "Trenton"

    MsgBox cities(1) & Chr(13) & cities(2) & Chr(13) _
        & cities(3) & Chr(13) & cities(4) & Chr(13) _
        & cities(5) & Chr(13) & cities(6)
End Sub

 








Related examples in the same category

1.Get the element in an array by index
2.Declaring a static array is similar to declaring a variable
3.Override the Option Base setting by specifically setting the lower bound in the array declaration
4.Declaring and Working with Fixed Arrays
5.Declaring array and setting bounds
6.Arrays are typically initialized inside a loop
7.Use the For Each...Next to assign value to an array
8.Use count function to count array
9.Use count function to sum array
10.Define and use multidimensional array
11.Create an Array, assign value and use Loop to show its value
12.Use LBound and UBound in for statement
13.Using a Two-Dimensional Array and Reference its elements
14.Understanding Errors in Arrays
15.Function Parameter type: Array
16.Assign range to an array
17.Declaring a static array is similar to declaring a variable, with one small exception
18.To assume that 1 is the lower index for your arrays
19.Multidimensional arrays
20.Sorts the List array in ascending order
21.Sorting an Array
22.Searching through an Array
23.Fill array by using a nested For- Next loop.
24.Referencing Elements in a Multi-dimensional Array
25.Convert number to String by using Array
26.Specifying the Index Range of an Array