Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Protect worksheets

  Asked By: Richard    Date: Oct 30    Category: MS Office    Views: 848
  

May I know how can I protect/unprotect my worksheets with password
using VBA macro?

Below is the example of protecting/unprotecting worksheet code without
the password:-

Protect:
ActiveWorkbook.Sheets("Current Database").Protect DrawingObjects:=True,
Contents:=True, Scenarios:=True

Unprotect:
ActiveWorkbook.Sheets("Current Database").Unprotect

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Amy Brown     Answered On: Oct 30

ActiveSheet.Unprotect "Password"
ActiveSheet.Protect "Password"

 
Answer #2    Answered By: Mandy Harvey     Answered On: Oct 30

It's actually very simple.
If you want your password  to be something like: "CreativePassword"
then use:

ActiveWorkbook.Sheets("Current Database").Protect "CreativePassword"
ActiveWorkbook.Sheets("Current Database").UnProtect "CreativePassword"

Remember, that you should also password protect  your vba  module
so that users can't look at the module to determine the password!

 
Didn't find what you were looking for? Find more on Protect worksheets Or get search suggestion and latest updates.




Tagged: