Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Protect Sheet With Password! Progmattically

Status
Not open for further replies.

MrsTFB

MIS
Oct 3, 2000
307
US
Hey guys,
I have a problem. I need to set protection on a worksheet. I can do this through the VBA, however, I want to use the password option so that someone doesn't simply remove my protection. I can't find that information anywhere. It doesn't show that step in the recording of the protection if you try recording the protection.

Anyone got any ideas on this???

Here's the code I'm using:
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Range("A2").Select


Thanks in advance,
mrsTFB in Tennessee
 
Hi Mrs TFB
Try this
ActiveSheet.Protect password:="ThisIsMyPassword"

Not too helpful tho as it can just be read and used
Better way is to use:

mPass = Inputbox("Enter Password")
Activesheet.protect password:= mPass

That way, no-one but you will know the password

Obviously, this will only need to be run if the sheet has been unprotected again

HTH
~Geoff~
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top