Consulting

Results 1 to 5 of 5

Thread: Select only Unlocked cell

  1. #1
    VBAX Contributor
    Joined
    Dec 2006
    Posts
    193
    Location

    Select only Unlocked cell

    Is there a way in VBA to have user restricted to selecting only unlockedcells in a work sheetThks

  2. #2
    VBAX Tutor
    Joined
    Jan 2008
    Posts
    262
    Location
    To enable only the unlocked cells to be selected:
    [vba]Sub SelectOnlyUnlocked()
    ActiveSheet.Protect
    ActiveSheet.EnableSelection = xlUnlockedCells
    End Sub[/vba]

    To unprotect the sheet again:
    [vba]Sub Unprotect()
    ActiveSheet.Unprotect
    End Sub[/vba]
    sassora

  3. #3
    VBAX Contributor
    Joined
    Dec 2006
    Posts
    193
    Location
    Thks for code sassora,I did find the code below prior to your reply which works on the sheet called Vredenburg.However I have added another sheet called Malsmebury and the code does not work on it can anyone help.

    Private Sub Workbook_Open()
      Worksheets("Vredenburg").EnableSelection = xlUnlockedCells
       
    End Sub

  4. #4
    VBAX Tutor
    Joined
    Jan 2008
    Posts
    262
    Location
    very intuitively:

    [vba]Private SubWorkbook_Open()
    Worksheets("Vredenburg").EnableSelection = xlUnlockedCells
    Worksheets("Malsmebury").EnableSelection = xlUnlockedCells
    End Sub[/vba]
    sassora

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,089
    Location
    or you may wish to try
    Private Sub Workbook_Open()
    With Worksheets("Vredenburg","Malsmebury")
    .EnableSelection = xlUnlockedCells
    End With
    End Sub
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

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