M
Mike-hime
In the workbook I am currently working on I declare all my public variables
at the module level and set them in the Auto_Open macro, so that Module1
looks like this:
Option Explicit
Public PSPDI_WS As Worksheet
Public PSPWO_WS As Worksheet
Public etc, etc...
__________________________________
Sub Auto_Open()
Set PSPDI_WS = Workbooks("MyWorkbook.xls").Worksheets("MySheet1")
Set PSPWO_WS = Workbooks("MyWorkbook.xls").Worksheets("MySheet2")
Set etc, etc...
End Sub
So that all procedures can call those worksheets at any time. However, I
find that after I have run a procedure and it ends, I can no longer use
PSPDI_WS to reference my previously set worksheet object when I run another
procedure (the same one again, or any other.) Why are my variables being
reset, and how do I fix it?
I thought a clue might be in the Static statement, but it appears that is
only used at procedure level and it's effects are lost when the code stops
executing.
Thx
-Mike-hime
at the module level and set them in the Auto_Open macro, so that Module1
looks like this:
Option Explicit
Public PSPDI_WS As Worksheet
Public PSPWO_WS As Worksheet
Public etc, etc...
__________________________________
Sub Auto_Open()
Set PSPDI_WS = Workbooks("MyWorkbook.xls").Worksheets("MySheet1")
Set PSPWO_WS = Workbooks("MyWorkbook.xls").Worksheets("MySheet2")
Set etc, etc...
End Sub
So that all procedures can call those worksheets at any time. However, I
find that after I have run a procedure and it ends, I can no longer use
PSPDI_WS to reference my previously set worksheet object when I run another
procedure (the same one again, or any other.) Why are my variables being
reset, and how do I fix it?
I thought a clue might be in the Static statement, but it appears that is
only used at procedure level and it's effects are lost when the code stops
executing.
Thx
-Mike-hime