Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retaining array values in procedures

Status
Not open for further replies.

hdtvguy

Technical User
Jan 6, 2003
6
CA
Hi,

Am a newbie to VBA for excel, have left the spreadsheet's commands to come over to the "dark side" [wink]

I've created a program that uses 8 subroutines to complete my task. The 1st sub calls the rest in order. In sub 4() I Dim an array, find 2 index values and use those to Redim the array - TaskCount(Countmax,Taskmax).

For the most part it all works. Then I decided to clean up the program and instead of duplicating the creation and finding of values for TaskCount in sub 6() and sub 7(), I thought I would reuse the arrays values.

For my trouble all I get is an array of values being zero or "Subscript out of range" Runtime error 9 message. I tried using PUBLIC and STATIC declarations, but to no avail. So I searched the "Helps" and the net and can not find any definitive information of how to reuse an array in more than one procedure inside a module.

Thanks for any help °°°Panasonic Hi&Lo Def WebPage°°°
 
Put the declarations in the Declarations section of the module. Everything there is available to all procedures in the module. Use Private for variables not to be made available OUTSIDE the module,

Private ary() as ..... Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top