Vba password prompt on Excel macro / password to restrict access to macros
Results 1 to 4 of 4

Thread: Vba password prompt on Excel macro / password to restrict access to macros
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Nov 2005
    Posts
    58
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Vba password prompt on Excel macro / password to restrict access to macros

    Hi, I hope this is an easy one someone could help with - how do you put a password prompt in a macro so that it brings up a message box asking the user to enter a password before the macro runs successfully? Also is it possible to password restrict all macros so that no one came go in and alter the script/text - only you can see and edit with the password? Thanks in advance. David

  2. #2
    Board Regular
    Join Date
    Oct 2007
    Location
    Kuwait
    Posts
    449
    Post Thanks / Like
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Vba password prompt on Excel macro / password to restrict access to macros

    You can use the below lines before your VBA code

    Code:
    Sub ABC()
    
    Dim Pass As String
    Pass = "Test"
    
    If InputBox("Please enter the password to run the macro") <> Pass Then
        MsgBox "Incorrect password !", vbExclamation, "Error"
        Exit Sub
    End If
    
    'place your VBA code here
    
    End Sub
    To protect the VBE, click on Tools > VBA Project Properties > Protection > Password

    Check the List of BB codes


  3. #3
    Board Regular
    Join Date
    Nov 2005
    Posts
    58
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Vba password prompt on Excel macro / password to restrict access to macros

    Many thanks.

  4. #4
    Board Regular
    Join Date
    Oct 2007
    Location
    Kuwait
    Posts
    449
    Post Thanks / Like
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Vba password prompt on Excel macro / password to restrict access to macros

    You are welcome

    Check the List of BB codes


Some videos you may like

User Tag List

Tags for this Thread

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
  •