I still don't think you're there with your title - try something that describes the problem, "Help understanding arrays", perhaps.
To answer your main question an array is a variable which has multiple elements, referenced by an index number (or numbers, but let's not go there yet).
So, for example, if I wanted to write a VBA program to ask for three numbers I could code this...
That would work, but if I wanted to get 10 numbers, or 100, or even more it would get very, very long-winded and be hard to work with, so I could define an array, like so...
Functionally these two programs are identical, but the second one can be expanded to allow for the input of any number of numbers, just by changing the value assigned to HowManyNumbers.
All of the numbers input are stored in the array GetNumber, but each one is stored in a unique element of that array, referenced by number, so if I wanted to output the first number entered I could say
More importantly I can deal with the numbers one at a time by putting them inside a For...Next loop, so I could output the numbers in the order they were entered with the code...
Arrays are absolutely essential to efficient coding, because they allow you to deal with sets of values, rather than having to reference each one individually. I don't mean to be rude, but if you're taking a VBA course shouldn't they be teaching you this sort of thing?
Bookmarks