ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Load a static array at procedure level (https://www.excelbanter.com/excel-programming/355690-load-static-array-procedure-level.html)

XP

Load a static array at procedure level
 
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 procedu
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.

Dave Peterson

Load a static array at procedure level
 
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

XP wrote:

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 procedu
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.


--

Dave Peterson


All times are GMT +1. The time now is 08:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com