I have an excel spreadsheet which I want 1 worksheet not be able to be deleted.
I've found the following VBA but keep getting a runtime error:
In Modules > Module 1, I have this:
Sub UnprotectBook()
ThisWorkbook.Unprotect
End Sub
In the Worksheet code, I have this:
Private Sub Worksheet_Deactivate()
ThisWorkbook.Protect Structure:=True, Windows:=False
Application.OnTime Now, “UnprotectBook”
End Sub
When I visit the sheet and then leave it, I get a runtime 1004 error on the “Application.OnTime” line.
I’m still learning basis VBA so any help would be greatly appreciated!
Thanks in advance.
Bookmarks