Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,570
- Office Version
- 365
- 2016
- Platform
- Windows
I have variable ws_form declared publicly as a worksheets at the workbook level of my code.
In the workbook open event, I set the variable:
At the end of my workbook open code, if I check to see if the variable has been declared properly, ws_form.name does return a result of "Form"
I have code in my userform button that refers to actions needed on worksheet "Form".
At this point, it appears as though I have lost the association of ws_form with worksheets("Form"). If I test ws_form.name, I get an Object required error. If I've declared ws_form globally through the PUblic declaration, shouldn't it be retained throughout the project? Any idea why I Have lost it?
In the workbook open event, I set the variable:
Code:
Private Sub Workbook_Open()
Set wb_demo1 = Workbooks("demo1.xlsm")
Set ws_form = wb_demo1.Worksheets("Form")
End Sub
At the end of my workbook open code, if I check to see if the variable has been declared properly, ws_form.name does return a result of "Form"
I have code in my userform button that refers to actions needed on worksheet "Form".
Code:
Private Sub btn_proceed_Click()
Unload Me
With ws_form
.Unprotect
.Range("O3").Value = emplnum
.Range("O4").Value = eqtnum
.Activate
.Protect
End With
End Sub
At this point, it appears as though I have lost the association of ws_form with worksheets("Form"). If I test ws_form.name, I get an Object required error. If I've declared ws_form globally through the PUblic declaration, shouldn't it be retained throughout the project? Any idea why I Have lost it?