how to declare Pub Const String Array ?

  • Thread starter Thread starter dick
  • Start date Start date
D

dick

can someone please show me how to declare a Public Constant String
Array? With shortened spelling below:

Pub Const C as String = "jones" works OK
Pub Const C(2) as String = "jones","smith" does not work

What to do? I would like to be able to index in an array of strings to
get replacement values for stuff in columns H,I,J etc. by using an
index of 18,19,20 etc.

Thanks
 
An array isn't a constant and can't be initialized as a constant, so you
will just have to initialize the variable.

Dim C as Variant
C = Array("Jones","Smith")

or
Dim C(1 to 2) as String
C(1) = "Jones"
C(2) = "Smith"

You can make your declarations public at the top of the module outside any
procedure and use a procedure to initialize them. Then, unless you reset
the VBE, you should be able to treat them like constants.
 
Back
Top