I have this private function before closing a workbook:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call SO
End Sub
Sub SO()
Worksheets("setUp").Unprotect Password:="xcxcxcxc"
Sheets("setUp").Visible = True
If Range("NOP").Value < Now Then
Range("NOC").Value = Now
Else
Range("NOC").Value = Range("NOP").Value + 0.00012
End If
Worksheets("setup").Protect Password:="xcxcxcxc"
SO ais meant to perform some updates on some protected and hidden sheets before closing. SO runs FINE run by itself... HOWEVER it falls over (at this stage: "Range("NOC").Value = Now") unable to update information on a locked sheet when called by the private function. What am I doing wrong??
'
The Sub F8s fine by itself, but unable to conduct the same operation when called by a another sub that closes the workbook (thereby engaging the private function before closing)
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call SO
End Sub
Sub SO()
Worksheets("setUp").Unprotect Password:="xcxcxcxc"
Sheets("setUp").Visible = True
If Range("NOP").Value < Now Then
Range("NOC").Value = Now
Else
Range("NOC").Value = Range("NOP").Value + 0.00012
End If
Worksheets("setup").Protect Password:="xcxcxcxc"
SO ais meant to perform some updates on some protected and hidden sheets before closing. SO runs FINE run by itself... HOWEVER it falls over (at this stage: "Range("NOC").Value = Now") unable to update information on a locked sheet when called by the private function. What am I doing wrong??
'
The Sub F8s fine by itself, but unable to conduct the same operation when called by a another sub that closes the workbook (thereby engaging the private function before closing)