Delete Macro

P

Pamela

Hi Guys!!!
I added this code this code and now I want to delete it:

Private Sub Workbook_Open()
'If you have different passwords
'for each Worksheet.
Sheets(1).Protect Password:="Secret", _
UserInterFaceOnly:=True


Sheets(3).Protect Password:="Secret", _
UserInterFaceOnly:=True


'Repeat as needed.
End Sub

I when inside (alt F11) and selected and delete but when I reopen the
workbook still is protected.
How I can delete the proteccion from the workbook?

thank you:
Pamela xoxo
 
G

Gord Dibben

The last statement in your now-deleted code protected the worksheets.

Deleting the code does not unprotect them.

Run this macro to unprotect all the sheets then save the workbook again.

Sub UnprotectAllSheets()
Application.ScreenUpdating = False
Dim N As Single
For N = 1 To Sheets.Count
Sheets(N).Unprotect Password:="Secret"
Next N
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP
 
P

Pamela

The last statement in your now-deleted code protected the worksheets.

Deleting the code does not unprotect them.

Run this macro to unprotect all the sheets then save the workbook again.

Sub UnprotectAllSheets()
    Application.ScreenUpdating = False
    Dim N As Single
    For N = 1 To Sheets.Count
        Sheets(N).Unprotect Password:="Secret"
    Next N
    Application.ScreenUpdating = True
End Sub

Gord Dibben  MS Excel MVP








- Show quoted text -

Thank you!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top