LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 399
Default 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



 
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
Declare variable as what? N E Body Excel Programming 6 October 28th 04 01:06 AM
Declare Variable zapatista66[_14_] Excel Programming 0 October 7th 04 05:02 PM
Declare Variable zapatista66[_12_] Excel Programming 2 October 7th 04 04:55 PM
Declare Variable zapatista66[_13_] Excel Programming 0 October 7th 04 04:13 PM
Declare Variable zapatista66[_11_] Excel Programming 1 October 7th 04 03:23 PM


All times are GMT +1. The time now is 06:32 PM.

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

About Us

"It's about Microsoft Excel"