Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

arrays

ResolvedVersion 2003

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

Excel tip:

Make macros work in newer versions of Excel

If you have created macros in Excel 97 or 2000 that you want to be able to use in 2002/XP or 2003, you may need to alter the macro security settings in the newer version of Excel you are using.

To do this, go to Tools - Options - Security.

Select Macro Security and change the security setting to Low.

Tick the boxes next to 'Trust Add-ins' and 'Trust Visual Basic' and click OK.

After you have restarted Windows, you should then be able to use your macros created in earlier versions of Excel.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.08 secs.