Need help, vba giving error/not working even though it is coded to unprotect the sheet.

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
I am using this code be
Code:
Sheet3.Unprotect password:="Secret"
' my code
Sheet3.protect password:="Secret"
before every code. I have like 25 vba linked in different wierd ways..

Everytime I run the code it says sheet is protected, "Runtime error 1004, the cell or chart you are trying to change is protected"...weird because I did not even protect it manually (alt > t> P > p 'way).

Can someone please advice?

Thanks
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
This is the oneI use to unprotect sheets.

Unprotect Multiple Sheets<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p> </o:p>
Sub Macro()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
If wSheet.ProtectContents = True Then
wSheet.Unprotect Password:="password"
Else
wSheet.Unprotect Password:="password"
End If
Next wSheet
End Sub
 
Upvote 0
Where do i apply this code..I have like 25 codes remember?

And I dont want sheet3 to be unlocked anytime....:biggrin:


Thanks again!
 
Upvote 0
Sorry, I thought you were looking to unprotect multiple sheets in a workbook. Good luck with your search
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top