Specifying the Index Range of an Array : Array « Data Type « VBA / Excel / Access / Word






Specifying the Index Range of an Array

 
Sub ArrayExample() 
    Dim acWeeklySales(1 To 7) As Currency 
    Dim n As Integer 
    Dim sDay As String 

    acWeeklySales(1) = 55100.44 
    acWeeklySales(2) = 43666.43 
    acWeeklySales(3) = 67004.11 
    acWeeklySales(4) = 87121.29 
    acWeeklySales(5) = 76444.94 
    acWeeklySales(6) = 98443.84 
    acWeeklySales(7) = 87772.37 

    For n = 1 To 7 
        sDay = Choose(n, "Mon", "Tue", "Wed", "Thu","Fri", "Sat", "Sun") 
        Debug.Print"Sales for " & sDay & " were $" & acWeeklySales(n) 
    Next 

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.Using a One-Dimensional Array
11.Define and use multidimensional array
12.Create an Array, assign value and use Loop to show its value
13.Use LBound and UBound in for statement
14.Using a Two-Dimensional Array and Reference its elements
15.Understanding Errors in Arrays
16.Function Parameter type: Array
17.Assign range to an array
18.Declaring a static array is similar to declaring a variable, with one small exception
19.To assume that 1 is the lower index for your arrays
20.Multidimensional arrays
21.Sorts the List array in ascending order
22.Sorting an Array
23.Searching through an Array
24.Fill array by using a nested For- Next loop.
25.Referencing Elements in a Multi-dimensional Array
26.Convert number to String by using Array