+ Reply to Thread
Results 1 to 3 of 3

Not allow user to select a locked cell

  1. #1
    CoolCyber
    Guest

    Not allow user to select a locked cell

    Hi,

    How can i not allow user to select a locked cell? I want to do it using VBA.
    I can do it in gui, by unselecting the "allow select locked cells" in
    protection. But when i close and open that option is checked again. so i
    want to do it in the code. as i am unprotecting and protecting the sheet in
    it.
    I do it as
    sheet2.unprotect("password")
    sheet2.protect("password")

    after this is done, the user can select the cell but he can't modify it. any
    help is appreciated.

    thanks



  2. #2
    Tom Ogilvy
    Guest

    Re: Not allow user to select a locked cell

    Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    if Target.Address = "$A$10" then
    Range("B10").Select
    End if
    End Sub

    Right click on the sheet tab and select view code. Paste in code like the
    above adjusted to suit your requirements.

    --
    Regards,
    Tom Ogilvy

    "CoolCyber" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > How can i not allow user to select a locked cell? I want to do it using

    VBA.
    > I can do it in gui, by unselecting the "allow select locked cells" in
    > protection. But when i close and open that option is checked again. so i
    > want to do it in the code. as i am unprotecting and protecting the sheet

    in
    > it.
    > I do it as
    > sheet2.unprotect("password")
    > sheet2.protect("password")
    >
    > after this is done, the user can select the cell but he can't modify it.

    any
    > help is appreciated.
    >
    > thanks
    >
    >




  3. #3
    derrida derider
    Guest

    RE: Not allow user to select a locked cell

    Try:
    ActiveSheet.EnableSelection = xlUnlockedCells

    Of course ActiveSheet can be replaced with Sheets("whatever") if you want to
    specify it for a specific worksheet.

    "CoolCyber" wrote:

    > Hi,
    >
    > How can i not allow user to select a locked cell? I want to do it using VBA.
    > I can do it in gui, by unselecting the "allow select locked cells" in
    > protection. But when i close and open that option is checked again. so i
    > want to do it in the code. as i am unprotecting and protecting the sheet in
    > it.
    > I do it as
    > sheet2.unprotect("password")
    > sheet2.protect("password")
    >
    > after this is done, the user can select the cell but he can't modify it. any
    > help is appreciated.
    >
    > thanks
    >
    >
    >


+ Reply to Thread

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