Link to home
Start Free TrialLog in
Avatar of Tocogroup
TocogroupFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How do I declare a public array variable in Excel VBA ?

Hi,
I am trying to declare a public variable array in Excel VBA as follows :

Public Qty(10) As String

.....but when I reference the array in my Sub it returns the following error :

"Constants, fixed length strings, arrays, user-defined types and Declare statements not allowed as Public members of object modules"

I'm able to reference other variables as Public but not the array. The variables are held in a Class Module called c_Invoice (I'm not sure how this differs from other Modules).

Any ideas
Regards
Toco
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

You can't do what you want. You have to create a property that accesses the array. And you have to define the array as private to the class.

Kevin
Avatar of Tocogroup

ASKER

Excuse my ignorance but how do I do that ? I'm not sure what you mean.
Toco
ASKER CERTIFIED SOLUTION
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial