Results 1 to 6 of 6

Lock Row for editing

Threaded View

  1. #1
    Registered User
    Join Date
    02-08-2016
    Location
    Wembley
    MS-Off Ver
    2016
    Posts
    3

    Lock Row for editing

    Hi all,

    I saw a thread that was exactly what I needed:

    http://www.excelforum.com/excel-gene...down-list.html

    It gives a drop down list and a password required for the "name" selected from the list. Each "name" in the drop down list has its own unique password.

    I would like to take this further by locking the row, but only a selected range on the row, e.g. A4:S4, not the entire row. The only thing is the drop down list will be on the row as well, e.g. Cell Q4. Therefore, when a "name" is selected from the drop down list in Cell Q4, and IF, and ONLY IF, the correct password is entered, then the row with the selected range will be locked for editing. This will include Cell Q4, therefore, once the password is entered it cannot be changed without "unprotecting" the sheet.

    Is there a code that can be added to make the above work to the following code:

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    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
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Any help is much appreciated!

    Thanks

    Ecko
    Last edited by FDibbins; 02-08-2016 at 07:31 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Lock individual cells to prevent editing.
    By TomRet in forum Excel General
    Replies: 3
    Last Post: 01-06-2015, 10:50 PM
  2. lock only seclected cells for viewing and editing
    By robin.das077 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-17-2012, 03:58 AM
  3. How lock for editing
    By td3601 in forum Excel General
    Replies: 2
    Last Post: 05-18-2012, 11:13 AM
  4. lock cells from editing
    By associates in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-28-2008, 11:58 PM
  5. [SOLVED] How do I lock some fields but allow editing for others in excel
    By S.Sharif in forum Excel General
    Replies: 1
    Last Post: 12-12-2005, 11:10 PM
  6. [SOLVED] Lock Header Rows from Editing
    By HotRod in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-11-2005, 12:35 PM
  7. [SOLVED] lock cells for editing-pawan
    By Pawan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2005, 09:06 AM

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