Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Procedure level array not recognised at module level

I wonder if anybody can explain this?

In developing a new program I declared a variable with indeterminate
dimension at module level (to make it available to any procedure) (e.g. Dim
variable() ).
I then reDimmed it at procedure level (to reinitialise the values before
working with it €“ i.e. reDim variable(array size)).
Then I used it within another procedure (e.g. sub AnotherProcedure()€¦€¦.
variable(subscript) = a value€¦€¦end sub, and it worked exactly as expected.

I then renamed "AnotherProcedure()" as I had rejigged the flow of the
program e.g. to sub DifferentName, only to find that it no longer recognised
the Dimmed variable within the module and came out with an error (subscript
out of range).

I then decided instead to create a new procedure with the required name,
then copy the old contents into it and it worked fine again!!

Is there a reason for this or is it some unknown quirk of Excel VBA?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default Procedure level array not recognised at module level

Have you declared the variable as public eg:

Public variable() as variant in you rmodule level declaration? If you
haven't, and haven't declared "Option Explicit" at the start of your module
that could explain the behaviour.

"Numskull" wrote:

I wonder if anybody can explain this?

In developing a new program I declared a variable with indeterminate
dimension at module level (to make it available to any procedure) (e.g. Dim
variable() ).
I then reDimmed it at procedure level (to reinitialise the values before
working with it €“ i.e. reDim variable(array size)).
Then I used it within another procedure (e.g. sub AnotherProcedure()€¦€¦.
variable(subscript) = a value€¦€¦end sub, and it worked exactly as expected.

I then renamed "AnotherProcedure()" as I had rejigged the flow of the
program e.g. to sub DifferentName, only to find that it no longer recognised
the Dimmed variable within the module and came out with an error (subscript
out of range).

I then decided instead to create a new procedure with the required name,
then copy the old contents into it and it worked fine again!!

Is there a reason for this or is it some unknown quirk of Excel VBA?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Procedure level array not recognised at module level

I cannot reproduce this behaviour.

Can you post a simple example of the code?

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Numskull" wrote in message
...
I wonder if anybody can explain this?

In developing a new program I declared a variable with indeterminate
dimension at module level (to make it available to any procedure) (e.g.
Dim
variable() ).
I then reDimmed it at procedure level (to reinitialise the values before
working with it - i.e. reDim variable(array size)).
Then I used it within another procedure (e.g. sub AnotherProcedure()...
variable(subscript) = a value..end sub, and it worked exactly as expected.

I then renamed "AnotherProcedure()" as I had rejigged the flow of the
program e.g. to sub DifferentName, only to find that it no longer
recognised
the Dimmed variable within the module and came out with an error
(subscript
out of range).

I then decided instead to create a new procedure with the required name,
then copy the old contents into it and it worked fine again!!

Is there a reason for this or is it some unknown quirk of Excel VBA?



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
Load a static array at procedure level XP Excel Programming 1 March 10th 06 04:27 PM
Using macro to convert single level BOM to Multi Level BOM andrew_chong Excel Programming 0 February 7th 06 08:57 PM
Stopping a 'multi-level' procedure Neal Zimm Excel Programming 1 February 25th 05 12:58 AM
Declaring array constants at module level Microsoft Forum Excel Programming 2 January 24th 05 06:31 PM
Why, when I create workbook-level name does it jump it to Sheet-level ? Charles Jordan Excel Programming 1 November 5th 03 08:43 PM


All times are GMT +1. The time now is 11:34 AM.

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

About Us

"It's about Microsoft Excel"