Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default declaring public variables

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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default declaring public variables

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)


"Loane Sharp" wrote in message
...
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





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default declaring public variables

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?

--
Regards,
Tom Ogilvy


"Loane Sharp" wrote in message
...
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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Declaring variables in Module vs. Public Jeff Excel Discussion (Misc queries) 5 November 19th 07 08:27 PM
Declaring Variables Public ob3ron02[_9_] Excel Programming 1 October 25th 04 06:11 PM
Declaring Variables Public ob3ron02[_8_] Excel Programming 1 October 25th 04 02:14 PM
declaring a public array JT[_2_] Excel Programming 3 July 27th 04 11:18 PM
Declaring Public Procedure mac Excel Programming 3 December 3rd 03 05:01 PM


All times are GMT +1. The time now is 02:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"