declaring public variables

L

Loane Sharp

Hi there

The following is most bizarre!

In my VBA project I've declared several public variables as normal (ahead of
all procedures) ... Public ctrNegInv, ctrPosInv As Integer, etc.

I set the values in one procedure and then execute a second procedure but,
when the variable is encountered in the second procedure, it appears to be
empty and I get a "Subscript out of range" error.

For instance, if I hover the cursor over the variable in the variable
declarations section, it says ctrNegInv = Empty, whereas if I hover the
cursor in the procedure where I set it's value it says ctrNegInv=0, and
further if I hover the cursover in the subsidiary or later procedures I get
ctrNegInv = Empty.

Can I be going mad?

Best regards
Loane
 
B

Bob Phillips

Hi Loane,

You aren't declaring the same variable in one of those procedures by any
chance?

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
T

Tom Ogilvy

Is the variable declared in a standard module, the type you get with
Insert=>Module and in the same project as the procedures that want to use
it?
 

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