Consulting

Results 1 to 2 of 2

Thread: Show messagebox if user selects locked cells

  1. #1
    VBAX Contributor
    Joined
    Aug 2007
    Posts
    165
    Location

    Show messagebox if user selects locked cells

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If ActiveSheet.ProtectContents = True Then
    If ActiveCell.Locked = True Then
    MsgBox "Select cells are locked"
    End If
    End If
    End Sub

    Hi experts

    I have the following vba code but when i add it to the worksheet and lock the cells i cannot get the message to apear if the users trys to click into a locked range of cells.......

    not sure what i am doing wrong

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It works fine for me although the code should be

    [vba]

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Me.ProtectContents = True Then
    If Target.Locked = True Then
    MsgBox "Select cells are locked"
    End If
    End If
    End Sub
    [/vba]

    Did you put the code in the worksheet code module?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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