Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Load a static array at procedure level | Excel Programming | |||
Using macro to convert single level BOM to Multi Level BOM | Excel Programming | |||
Stopping a 'multi-level' procedure | Excel Programming | |||
Declaring array constants at module level | Excel Programming | |||
Why, when I create workbook-level name does it jump it to Sheet-level ? | Excel Programming |