Results 1 to 8 of 8

Password for Dropdown List?

Threaded View

  1. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Password for Dropdown List?

    Something like this put in the SHEET module to watch cell B7, edit the password constants at the top of the macro:

    Option Explicit
    Const Mike As String = "Mike1"
    Const Alan As String = "Alan1"
    Const Bob As String = "Bob1"
    Const Pete As String = "Pete1"
    
    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 "Mike"
                    If pwd <> Mike Then Oops = True
                Case "Bob"
                    If pwd <> Bob Then Oops = True
                Case "Alan"
                    If pwd <> Alan Then Oops = True
                Case "Pete"
                    If pwd <> Pete Then Oops = True
            End Select
            
            If Oops Then
                MsgBox "Bad password"
                cell = ""
            End If
        End If
    Next cell
    
    Application.EnableEvents = True
    End Sub
    Attached Files Attached Files
    Last edited by JBeaucaire; 09-02-2010 at 08:02 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

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