how to declare Pub Const String Array ?

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
 
T

Tom Ogilvy

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.
 

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