Sally has attended:
Excel Advanced course
Arrays
What is the purpose of an array? I've looked them up online and I am not sure what they are for, can they help in reducing the size of files?
RE: Arrays
Hi Sally
In computer terms an array is a data structure consisting of elements that are accessed by indexing.
So Arrays make it possible to refer to a series of variables by the same name and to use an index to tell them apart.
This helps create smaller and simpler code by using loops that deal efficiently with any number of cases by using the index number. This usually speeds up the running of the program.
Arrays are useful when you must store a number of values of the same type, but you do not know how many, or you do not want to create individual variables to store them all.
The indexing in an array by default begins at 0 so declaring an array as
Dim SalesYear(5) as Integer
will allow you to store 6 years (0 t0 5)
Then in the code SalesYear(3) will return the value stored in that section of the array. This is refered to a Static array
You can also program a dynamic array. I this case you define the array but not the size. This can be defined later as seen below:
Dim SalesYear as Integer
ReDim SalesYear (1 To 20)
NB You can change the size of a dynamic array, but not the data type
Hope this helps
Regards
Carlos