Userforms, switching sheets
That is because WSDates only works in the sub you create it. This is
called scope of the variable.
As soon as the sub is finished, the memory of the variable will be
unassigned and you won't be
able to call it anymore.
You would need to make the variable public.
Another approach would be a Public sub which activates the sheet you
submit:
Public Sub ActivateSheet (WorksheetName as string)
On error goto EHandler
worksheets(WorksheetName).activate
Ehandler:
end function
hth
Carlo
On Dec 25, 1:14*pm, Charlie wrote:
Ok, I named my worksheets, but when my code doesn't recognize the names once
I get out of the Private Sub UserForm_Initialize() *code. *Do I need to make
these name public? *I don't understand everything I know about this
(obviously!)
...this is what I did:
Private Sub UserForm_Initialize()
Dim wsSchedules As Worksheet
Dim wsDates As Worksheet
Set wsSchedules = Worksheets("Sheet1")
Set wsDates = Worksheets("sheet2")
...and I can use
wsDates.Activate
and it's works, but once in a different sub() from another control it
doesn't recognize wsDates???
|