i have this code in my workbook that runs each time a user saves the workbook.
problem is that i want to password protect the sheet and then return to the sheet the user was previously working in. so looking for 2 modifications to my code below:
1. to unprotect the sheet, then protect it when done
2. return the user to whatever sheet they were working in when they saved the workbook
thanks in advance for any help you can give
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Application.ScreenUpdating = False
Sheets("Vacations").Select
'would like code here to unprotect sheet ("Vacations"), pw = "password"
Range("a2").Value = FormatDateTime(Now, vbShortDate)
Range("B2").Value = FormatDateTime(Now, vbShortTime)
'would like code here to protect sheet ("Vacations"), pw = "password"
'would like code here to go back to sheet user had selected before saving
Application.ScreenUpdating = True
End Sub
problem is that i want to password protect the sheet and then return to the sheet the user was previously working in. so looking for 2 modifications to my code below:
1. to unprotect the sheet, then protect it when done
2. return the user to whatever sheet they were working in when they saved the workbook
thanks in advance for any help you can give
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Application.ScreenUpdating = False
Sheets("Vacations").Select
'would like code here to unprotect sheet ("Vacations"), pw = "password"
Range("a2").Value = FormatDateTime(Now, vbShortDate)
Range("B2").Value = FormatDateTime(Now, vbShortTime)
'would like code here to protect sheet ("Vacations"), pw = "password"
'would like code here to go back to sheet user had selected before saving
Application.ScreenUpdating = True
End Sub