View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
David David is offline
external usenet poster
 
Posts: 195
Default How to declare a variable for several subs

Bob Phillips wrote

Declare them as public variables, before any macro, in a standard code
module

Public NumRows as Long
Public NumCols as long


Sub macro1(0
...
End Sub


etc.


OK, after preceding my subs with the Public declarations, I added these
lines to the Workbook_Open event:

NumRows = Range("Name_Copy").Rows.Count
NumCols = Range("Name_Copy").Columns.Count

and things seem to work after removing those lines from individual Subs in
my standard Module.

Is that the proper way to handle things?

--
David