+ Reply to Thread
Results 1 to 5 of 5

Thread: Password Protection

  1. #1
    Registered User
    Join Date
    10-16-2010
    Location
    bangalore
    MS-Off Ver
    Excel 2007
    Posts
    93

    Password Protection

    Hi,

    have a time tracker sheet in that there are 2 buttons are there for capturing start and end time. I need to give allow users to edit ranges for only for the column I (Remarks Column in the sheet) remaining all column should be non-editable. I have locked all the cells expect the column I and protect the sheet with password. But when I click on the start time its asking the password to generate the time. Unless I give the password time wont come.. I want this should come without asking password..how can I do this?

    Attached the sheet for your reference...
    Attached Files Attached Files

  2. #2
    Forum Moderator Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    5,953

    Re: Password Protection

    With protected worksheets, if you want macros to act on protected cells you have to un-protect them first. This can be done quite easily by adding two lines to your code - one at the beginning and one atthe end (to re-protect your cells).
    Sub anwitha()
    Sheets("timesheet").Unprotect Password:="your_password"
    .
    .
    Other code here
    .
    .
    Sheets("timesheet").Protect Password:="your_password"
    End Sub
    So users can't open the VB editor and see your password, you can protect the vba by clicking Tools -> VBA Project Properties -> Protection and check the 'Lock project' box and set a password. While superusers can break sheet and vba password protection in minutes, it will keep the average user from breaking in and changing anything.

    Hope that helps!

  3. #3
    Registered User
    Join Date
    10-16-2010
    Location
    bangalore
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Password Protection

    I tried with this..but its not working..can u do it for the attached sheet which i have attached in this thread and then post?

    Thanks in advance...

    Note - do not proct the vb properties to view code.

  4. #4
    Registered User
    Join Date
    10-16-2010
    Location
    bangalore
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Password Protection

    pls help me.

  5. #5
    Forum Moderator Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    5,953

    Re: Password Protection

    Your code is working fine. If you actually have a password set (not a blank password) you have to add the bits after .Unprotect and .Protect as I showed above. Also note that cells F5:F8 do not contain the formula found in F9:F17. My guess is they probably should.

    I'd also recommend not using ActiveSheet.Unprotect / .Protect. Specify the sheet name.
    Sheets("Sheet1").Unprotect Password:="this is where your password goes"

+ 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.2.0