+ Reply to Thread
Results 1 to 6 of 6

Password protect macro button

  1. #1
    Registered User
    Join Date
    10-02-2012
    Location
    london, england
    MS-Off Ver
    Excel 2010
    Posts
    9

    Password protect macro button

    Hi All,

    I'm trying to password protect a macro buttom but not sure of how to do it based on the code I've been using for the macro?

    Help very much appreciated!

    Please Login or Register  to view this content.
    Gavin

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,661

    Re: Password protect macro button

    I'd suggest that you use an InputBox (to get the password) as the first thing you do in the subroutine. Then, if it is accepted, carry on, if not, exit the subroutine.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-02-2012
    Location
    london, england
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Password protect macro button

    Hi thanks for this really do appreciate your help.

    I'm not sure how to do an inputbox? I think I've got some code to do this but not sure how to push it into the existing code?

    This is what I've found?

    Please Login or Register  to view this content.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,661

    Re: Password protect macro button

    That's a specific type of InputBox with a specific type of input, namely a range, hence the reason for Set=.

    You can get away with dimming a variant variable and just using InputBox (not the app bit). Note that you can't mask the password characters with either of thes functions, which may or may not be a problem.

    So, you could just use pw=InputBox(...).

    Test the pw variable, if it's blank, either enter has been pressed with no data, or Cancel has been pressed.

    If you get data input, you can check it.

    Just type InputBox, select it and press F1 to see the Help for more details.

    Regards, TMS

  5. #5
    Registered User
    Join Date
    10-02-2012
    Location
    london, england
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Password protect macro button

    Hi sorry I'm being dumb I don't know how to input this into the code?

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,661

    Re: Password protect macro button

    Please Login or Register  to view this content.

    Not tested as I'm away from my computers but that should give you the idea.

    Regards, TMS

+ 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