Forum Discussion
saravanan24
May 04, 2023Copper Contributor
User Access in excel sheets with macro's
Hi, I am seeking a way to prevent writing on a sheet at the user level without using a protect password method, since we use macro's to transfer data from one sheet to another even its protected. W...
HansVogelaar
May 04, 2023MVP
One option is to protect the sheet, and then unprotect it at the beginning of a macro, and reprotect it at the end.
Another option is to protect the sheet in the Workbook_Open event procedure in the ThisWorkbook module with the UserInterfaceOnly argument set to True:
Private Sub Workbook_Open()
Worksheets("Sheet1").Protect Password:="Secret", UserInterfaceOnly:=True
End Sub
VBA code should then be able to manipulate the protected sheet without causing an error.