+ Reply to Thread
Results 1 to 3 of 3

Drop-down password

Hybrid View

Maschine10 Drop-down password 07-31-2017, 07:42 AM
LeoTaxi Re: Drop-down password 07-31-2017, 02:13 PM
Maschine10 Re: Drop-down password 08-01-2017, 02:32 AM
  1. #1
    Registered User
    Join Date
    07-31-2017
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    5

    Drop-down password

    Hello everybody,

    I'm currently facing an issue with the Dropdown-lists.
    I managed to allow that each requester in the dropdown list needs to type in there own password to be able to select there names.
    But I want the whole sheet to be protected, until you select your name. After which you are allowed to fill in data in a selected area.

    I used the following code:
    Option Explicit
    Const Marc As String = "Marc1"
    Const Nina As String = "Nina1"
    Const Lars As String = "Lars1"
    Const Ibo As String = "Ibo1"
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cell As Range
    Dim pwd As String
    Dim Oops As Boolean
    
    Application.EnableEvents = False
    
    For Each cell In Target
        If Not Intersect(cell, Range("B7")) Is Nothing And cell <> "" Then
            pwd = Application.InputBox("Password for " & cell & ":", _
                        "Enter Password", Type:=2)
            Select Case cell.Value
                Case "Marc"
                    If pwd <> Marc Then Oops = True
                Case "Nina"
                    If pwd <> Nina Then Oops = True
                Case "Lars"
                    If pwd <> Lars Then Oops = True
                Case "Ibo"
                    If pwd <> Ibo Then Oops = True
            End Select
            
            If Oops Then
                MsgBox "Bad password"
                cell = ""
            End If
        End If
    Next cell
    
    Application.EnableEvents = True
    End Sub
    Hope that someone can help me

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Drop-down password

    With extra sheet with Users and there passwords, to be hide
    and dynamic named range with users for the validation list


    Option Explicit
    
    Private Sub Worksheet_Activate()
    With Sheets("sheet1")
        .Unprotect Password:="test"
        .Range("B7") = ""
        .Range("B8", "F20").Locked = True
        .Protect Password:="test"
    End With
    End Sub
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim pwd As String, my_users As Range, pwdstored As String, free_range As Range
    Set free_range = Sheets("sheet1").Range("B8", "F20")
    If Target.Address = "$B$7" And Target <> "" Then
        With Sheets("Passwords").Range("A:A")
            Set my_users = .Find(Target, LookIn:=xlValues, lookat:=xlWhole)
            If Not my_users Is Nothing Then
                pwdstored = .Cells(my_users.Row, 2)
            Else
                MsgBox "Invalid User"
                Exit Sub
            End If
            pwd = Application.InputBox("Password for " & Target & ":", _
                        "Enter Password", Type:=2)
            If pwd = pwdstored Then
                Sheets("sheet1").Unprotect Password:="test"
                free_range.Locked = False
                Sheets("sheet1").Protect Password:="test"
            Else
                MsgBox "Bad password"
                Sheets("sheet1").Unprotect Password:="test"
                free_range.Locked = True
                Sheets("sheet1").Protect Password:="test"
            End If
        End With
    End If
    End Sub
    Kind regards
    Leo
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    07-31-2017
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    5

    Re: Drop-down password

    Hi Leo,

    thank you so much for your help!
    It works perfectly

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Drop-down password
    By Maschine10 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 07-31-2017, 07:35 AM
  2. Help needed - Need to password protect a drop down menu
    By brichardson1995 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-21-2016, 10:06 AM
  3. Making a password on the drop down list
    By ambrociano in forum Office 365
    Replies: 0
    Last Post: 12-09-2015, 04:12 AM
  4. Password for drop down menu
    By doveyp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-07-2015, 06:14 PM
  5. Password for drop down list
    By welshman010 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-21-2014, 09:43 PM
  6. change drop down list with password required
    By gccch in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-04-2014, 02:58 PM
  7. [SOLVED] Password for Drop Down List
    By JurekPol in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-30-2013, 08:20 PM

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