+ Reply to Thread
Results 1 to 7 of 7

Password Protection

  1. #1
    Registered User
    Join Date
    12-15-2003
    Location
    Wisconsin
    Posts
    25

    Cool Password Protection

    I have a sheet that is password protected. Is it possible to write a macro that will un-protect the sheet automatically, sort it and re-protect it, entering the password again automatically? And, if it is possible to do that, how can I password protect the macro, so that the user can't access the sheet protection password?
    ElsiePOA

  2. #2
    Forum Contributor
    Join Date
    06-01-2006
    Posts
    324
    Sub Macro1()

    Dim comment As String

    comment = InputBox("Enter Sort Password")

    If comment <> "12345" Then
    MsgBox ("Invalid Password")
    Exit Sub
    End If

    ActiveSheet.Unprotect Password:="55555"
    Columns("A:E").Select
    Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal
    ActiveSheet.Protect Password:="55555"

    End Sub

    Sort Password is set as 12345, Activesheet Password is set as 55555

    It's selecting Columns A:E and sorting by Column A

    Customize as you need to
    Google is your best friend!

  3. #3
    Chip Pearson
    Guest

    Re: Password Protection

    Password protection is notoriously weak in Excel, but it will
    keep the novice masses from changing things. Your code would look
    like

    Worksheets("Sheet1").Unprotect Password:="ABC"
    ' do the sort
    Worksheets("Sheet1").Protect Password:="ABC"

    You can password protect the VBA code (also very weak password
    protection). In VBA, go to the Tools menu, choose VBA Project
    Properties, then the Protection tab. Check "Lock project for
    viewing" and enter a password.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com



    "ElsiePOA"
    <[email protected]> wrote in
    message
    news:[email protected]...
    >
    > I have a sheet that is password protected. Is it possible to
    > write a
    > macro that will un-protect the sheet automatically, sort it and
    > re-protect it, entering the password again automatically? And,
    > if it
    > is possible to do that, how can I password protect the macro,
    > so that
    > the user can't access the sheet protection password?
    >
    >
    > --
    > ElsiePOA
    >
    >
    > ------------------------------------------------------------------------
    > ElsiePOA's Profile:
    > http://www.excelforum.com/member.php...fo&userid=3901
    > View this thread:
    > http://www.excelforum.com/showthread...hreadid=564433
    >




  4. #4
    Registered User
    Join Date
    12-15-2003
    Location
    Wisconsin
    Posts
    25

    Password Protection

    Thanks to both Chip and Bearacade for the prompt response. The problem is solved!

  5. #5
    AntnyMI
    Guest

    Re: Password Protection

    Elsie, this worked for you?
    I was able to get the various password prompts as instructed. However,
    anyone who navigates to Tools|Macros|Edit will be able to see the
    password typed in the code.

    Have you figured out a way to disable access to the Macro menu unless
    the correct password is entered?


    ElsiePOA wrote:
    > Thanks to both Chip and Bearacade for the prompt response. The problem
    > is solved!
    >
    >
    > --
    > ElsiePOA
    >
    >
    > ------------------------------------------------------------------------
    > ElsiePOA's Profile: http://www.excelforum.com/member.php...fo&userid=3901
    > View this thread: http://www.excelforum.com/showthread...hreadid=564433



  6. #6
    Registered User
    Join Date
    12-15-2003
    Location
    Wisconsin
    Posts
    25

    Password Protection

    Look at Chip Pearson's response to my inquiry. He tells you how to protect the macros. The protection doesn't kick in until after you have saved and closed the workbook. Next time you open it, all of the macros for that workbook will be password protected.

    Excel's protection is weak, but this will keep the average user from accessing the protected data.

  7. #7
    Forum Contributor
    Join Date
    11-20-2005
    Posts
    256
    Quote Originally Posted by AntnyMI
    Elsie, this worked for you?
    I was able to get the various password prompts as instructed. However,
    anyone who navigates to Tools|Macros|Edit will be able to see the
    password typed in the code.

    Have you figured out a way to disable access to the Macro menu unless
    the correct password is entered?
    Hi AntnyMI,

    You can hide the macro name from being visible in the 'Tools|Macros|Edit',
    by puting 'Option Private Module' at the top of the General module where your code resides.
    Thx
    Dave
    "The game is afoot Watson"

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1