Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: VBA password protect, input box

  1. #1
    Board Regular peterhinton's Avatar
    Join Date
    Mar 2016
    Location
    birmingham
    Posts
    336
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default VBA password protect, input box

    can I modify this simple VBA, so that rather than have the password "edit" in the code, when I run the macro I am prompted for an input box to pop up instead ?
    Code:
    Sub unprotect()
        ActiveSheet.unprotect Password = "edit"
    End Sub
    Last edited by peterhinton; Jan 13th, 2017 at 10:17 AM.
    before joining this forum, I would have said I was quite advanced with Excel....

    6 Months later and with 10 time more knowledge; I now see myself as a beginner....

    Thanks to All who have helped me out, you guys have literally got me where I am within my company

  2. #2
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    33,210
    Post Thanks / Like
    Mentioned
    40 Post(s)
    Tagged
    5 Thread(s)

    Default Re: VBA password protect, input box

    First off, that code is not correct - it's actually using "False" as a password. It should read:
    Code:
    ActiveSheet.unprotect Password:="edit"
    (see this for an explanation)

    To add an inputbox:
    [code]
    Code:
    ActiveSheet.unprotect Password:=Inputbox("Enter password")

  3. #3
    MrExcel MVP mikerickson's Avatar
    Join Date
    Jan 2007
    Location
    Davis CA
    Posts
    22,333
    Post Thanks / Like
    Mentioned
    19 Post(s)
    Tagged
    11 Thread(s)

    Default Re: VBA password protect, input box

    Code:
    ActiveSheet.Unprotect
    Will automatically display a "enter password" dialog if the sheet is password protected.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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