ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clear Dim Statments (https://www.excelbanter.com/excel-programming/348015-clear-dim-statments.html)

Nigel

Clear Dim Statments
 
I have some code on a workbook and I want to clear out all the dim statements
so I can use them again further down in the code

Is there any way this can be achieved

Jim Thomlinson[_4_]

Clear Dim Statments
 
The question is a little unclear. Is this a matter that within a single sub
routine you have declared some vairables and you want to clear them and reuse
them again in the same sub routine, or are you using the same variable name
in more than one sub?

For a quick and over simplified description, when you declare a varaible
within a Sub or Function a memory spot is reserved on the stack. That memory
spot will exist until the end of the procedure at which point the stack is
cleared and the variable is gone. The exception to this is if the vairable in
the sub was declared as static. If it was declared static or it was declared
globally then it is stored on the Heap and the memory allocation persists
until the program (spreadsheet) is closed. In any one procedure you can not
declare the same variable name twice. You can clear the value in the
variable, (make it 0, false, nothing, empty, "", ...). You can use the same
variable name in more than one sub. That is to say that you can declare "Dim
i As Integer" in as many subs as you want. Not sure if this helps but there
it is.
--
HTH...

Jim Thomlinson


"Nigel" wrote:

I have some code on a workbook and I want to clear out all the dim statements
so I can use them again further down in the code

Is there any way this can be achieved



All times are GMT +1. The time now is 07:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com