Can a worksheet object be declared globally in Excel VBA? -
I am restructuring several modules in an Excel 2003 workbook and declaring the same set of worksheets in each process in each Module goes; I want to declare them globally once. I can set the worksheet name in a literal form, for example:
public consult xlwkGSModel = "gs_model" string like
and then process In use:
... ActiveWorkbook.Worksheets (xlwkGSModel) .seel (1,1)
But there is a way to declare a worksheet object So that the code can be in the process:
... xlwkGSModel.Cells (1,1)
'1 enter a module
' 2 worksheet universal Announce the public variables in the module:
Public Exclave GSODellel as Worksheet
'Instant this public variable in 3 app load events.
> set the sub workbook open () xlwkGSModel = ActiveWorkbook.Worksheets ("gs_model") End sub
'You can now reference the gs_model worksheet with the XlwkGSModel variable
'For example
dim x string x = xlwkGSModel.Cells (1,1)
Comments
Post a Comment