How to declare a variable for several subs
David:
I am not an expert by any means, so what I do may not be the best way. But
if I have several Subs in one module and all need to act on the same
variables, I Dim the variables at the very top of the module before the
first Sub. Be careful, though - numbers and strings may not be at
zero-value when you hit a certain Sub, as they would be if you had declared
them in that Sub. I also must confess that while I know it works for
declaring variables and setting string and number values in one Sub to carry
over into another, I have had only limited success trying to get Workbook,
Worksheet, and Range variables to Set in one Sub and carry over into
another. Referring to my first statement, I'm probably doing something
amiss; if so, I'm sure someone else here can give the best way.
Ed
"David" wrote in message
...
I have a workbook I've been developing under XL2K in which I reference the
number of rows and columns in a named range in several VBA subroutines
within a single module:
NumRows = Range("Name_Copy").Rows.Count
NumCols = Range("Name_Copy").Columns.Count
Is there a way to make those available to all subs within my module
without
having to put them in each individual subroutine?
If so, I need exact syntax please.
--
David
|