Hey,
My understanding is when you "DIM" a variable, it creates room (memory space) for that variable and points to that space using the name you used in the DIM statement.
sets aside memory, within the subroutine or function you put in it that is the size of a "Double" and points to that memory spot using the name "LastRow".![]()
Dim LastRow as Double
When the subroutine hits an "END" it clears all the memory it was using for the Sub and gives back the memory and variables. This is called "Popped off the stack".
If you declare a Global variable, it can be seen by all the subroutines "within its scope" and you don't need to declare them in the individual subs.
Does that make sense to you???
Short story... In early computer days, there was this guy who liked to write fast code. He would challenge me often to race. I would always declare the variables that I knew would be used the most, first! Then when my code ran it wouldn't need to look through the whole list of variable names to find the spot in memory that held the value. He didn't think it mattered the order of the Dim statements but the computer needs to keep this list and then find the memory location where they are stored. BTW - just declaring the most used variables first kept me winning for a long time.
Bookmarks