+ Reply to Thread
Results 1 to 8 of 8

Password protect macros

  1. #1
    Registered User
    Join Date
    06-12-2008
    Posts
    8

    Exclamation Password protect macros

    Hi

    1st post on these forums.

    I recorded a couple of macros on excel last night, one hides certain rows then sorts by columns E and B then hides certain columns and protects the sheet. The other does pretty much the opposite, unprotects the sheet then unhides the columns, sorts by columns B and E then unhides the rows.

    My question is can I password protect the macro button so only authorised people can use it?

    The reason being the hiden rows and columns need to stay hidden and only certain people able to unhide them due to there being sensitive information on them.

    If theres no way of password protecting this any ideas on how I can keep these rows and columns from being unhidden by unauthorised people would be a great help.

    Thanks in advance for any help provided.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Welcome to the Forum. You could add this to the start of your code
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243
    hi all,

    Roy, you just beat me to this one!

    Ripps, Roy's suggestion will work for you but depending on how sensitive the information is & what skill level your Excel users have, this may not be sufficient protection - see the below link for further info on security within Excel:

    http://www.j-walk.com/ss/excel/faqs/protectionFAQ.htm

    hth,
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  4. #4
    Registered User
    Join Date
    06-12-2008
    Posts
    8

    Thanks

    Thanks alot guys. I will have a look over the info you have provided and give it a go later. Will update you when had the chance.

    Thanks for the warm welcome also!

  5. #5
    Registered User
    Join Date
    06-12-2008
    Posts
    8
    Quote Originally Posted by royUK
    Welcome to the Forum. You could add this to the start of your code
    Please Login or Register  to view this content.

    This works really well apart from when the password box comes up, if you press cancel the same thing happens as if you put the password in. I entered the desired password in the <> signs but is there anything else i need to so?

    Sorry I only have very basic knowledge of macros. Otherwise this would be perfect for what I need.

  6. #6
    Valued Forum Contributor
    Join Date
    03-23-2008
    Location
    Tennessee
    MS-Off Ver
    Office 2007
    Posts
    706

    Try this....

    Morning, ripps.

    I'm a vba newbie myself, but in the absence of a guru you may try this.

    First, replace "secret" with your password. This is the constant the macro is looking for in order to continue running the code.

    Leave the reaminder of the code the way it is. The <> symbols are actully less than and greater than symbols, telling the macro to exit if anything other than your password is entered.

    I'm sure that if I'm wrong one of the mods will correct me.

    Have a good one.

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Hutch is correct, you need to change the password by changing the constant "secret". Put your choice there.
    Last edited by royUK; 06-12-2008 at 10:11 AM.

  8. #8
    Registered User
    Join Date
    06-12-2008
    Posts
    8
    OK thanks alot people

+ 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