Load a static array at procedure level

X

XP

I am using Office 2003 on Windows XP.

I am trying to load a static array with data as follows:

At module level:
Private msColTotals() as String

In procedure:
ReDim msColTotals(7)
msColTotals = Array("L", "X", "Y", "AA", "AB", "AF", "AJ")

But this fails. Can someone please post example code to fix this so it will
run?

Thanks much in advance.
 
D

Dave Peterson

Private msColTotals() as String
becomes
Private msColTotals as Variant

And you can drop the ReDim statement, too.

That way you don't have to worry when you add another column.

If you need to loop through the array:

Dim iCtr as long

for ictr = lbound(msColTotals) to ubound(msColTotals)
....
next ictr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top