Hi all,
In order my VBA code to run in protected mode I have the below VBA codes:
As well as in the workbook:
However, when I right click in the tab of Sheet1 and protect manually with a password, then the VBA code needs also that code..
I want in the above codes to add a password, hence it could automatically and in the background the excel to unprotect itself and reprotect and so the VBA to work..
How should I change them?
Thanks in advance
In order my VBA code to run in protected mode I have the below VBA codes:
VBA Code:
Sub Edit_Sheet1()
'Unprotect Sheet1
Worksheets("Sheet1").Unprotect
'Do Something to Sheet1
'Reprotect Sheet1
Worksheets("Sheet1").protect
End Sub
As well as in the workbook:
VBA Code:
Private Sub workbook_open()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.protect UserInterfaceOnly:=True
Next ws
End Sub
However, when I right click in the tab of Sheet1 and protect manually with a password, then the VBA code needs also that code..
I want in the above codes to add a password, hence it could automatically and in the background the excel to unprotect itself and reprotect and so the VBA to work..
How should I change them?
Thanks in advance