Can You Help With This Code

rockyw

Well-known Member
Joined
Dec 26, 2010
Messages
1,196
Office Version
  1. 2010
Platform
  1. Windows
I want to protect sheet 2 (renamed Held) with a password. I got this but I can not make it work. I tried in a Module, sheet 1 and 2. Do I have to change this because I renamed my sheet? Thanks

Code:
With Sheet2
    .Protect Password:="wlw"
    .Visible = xlSheetVeryHidden
End With
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Switch Sheet2 with Sheets("Name of Sheet")
(keep the quotes around the name of your sheet)
 
Upvote 0
It still will not work. Should this be in a module, or sheet 2?

Code:
Sheets "Held"
    .Protect Password:="wlw"
    .Visible = xlSheetVeryHidden
End With

Is this right? Thanks for the help
 
Upvote 0
Code:
With Sheets("Held")
    .Protect Password:="wlw"
    .Visible = xlSheetVeryHidden
End With
 
Upvote 0
Sorry
I put that in a Module, now I get an (Invalide outside procedure) errer?

Code:
With Sheets("Held")
    .Protect Password:="wlw"
    .Visible = xlSheetVeryHidden
End With

Thank you for the help.
 
Upvote 0
Code:
Sub HideSheet ()
 
With Sheets("Held")
    .Protect Password:="wlw"
    .Visible = xlSheetVeryHidden
End With
 
End Sub
 
Upvote 0
I get no Error, but it will not work. I can open sheet 2 (Held) without a password. So sould this be in sheet one, workbook, or a module? Thanks
 
Upvote 0
Put the code into Module 1. Go to the worksheet and press Alt+F8. Choose the HideSheet Macro and press Run.
 
Upvote 0
OK that works, but how do I unhide it? Do I have to go into the view code area and reset sheet 2? Even the unhide option is gone. Thanks
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,841
Members
452,948
Latest member
UsmanAli786

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