+ Reply to Thread
Results 1 to 5 of 5

How to prevent double click event working on a protected cell

  1. #1
    Forum Contributor
    Join Date
    10-25-2016
    Location
    Derby, England
    MS-Off Ver
    MS 2013
    Posts
    228

    How to prevent double click event working on a protected cell

    Hi,

    I was wondering if someone could help me please?

    I have a double click sub that works fine but I would like it not to work on a protected cell.

    I've tried looking it up but the only answers I've found is by using a cancel button on a message box. I would prefer not to use a message box.

    Is there another way to do this?

    Here's my code.

    Please Login or Register  to view this content.
    Kind Regards
    Dan

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: How to prevent double click event working on a protected cell

    Your sub will not even be invoked if the user double-clicks on a locked cell when the sheet is protected, so I'm unclear on what you're looking for.

    First let's get terminology lined up: A cell can be locked or unlocked. A worksheet can be protected. If a sheet is protected, you can select options to restrict what a user can do to locked cells on that sheet. If a cell on a protected sheet is unlocked, then there are no restrictions on that cell.

    What is it you want to happen if the user double-clicks a locked cell on a protected sheet? Excel will display a dialog box telling the user that the action is not allowed, even if you have a Worksheet_BeforeDoubleClick sub.

    By the way, your assignment to the cell probably works but is misleading. You may want to use
    Please Login or Register  to view this content.
    Last edited by 6StringJazzer; 07-29-2017 at 09:11 AM.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    10-25-2016
    Location
    Derby, England
    MS-Off Ver
    MS 2013
    Posts
    228

    Re: How to prevent double click event working on a protected cell

    Hi Jeff,

    Thank you for replying.

    To start with the cell is unlocked on a protected sheet. I double click in that range and it puts the time in. After I've done a few other things on my sheet I enter my password and it protects certain cells.

    When I double click the cell again after its been protected it comes up with "Run time error 1004" Application defined or object error, and when I debug it it highlights
    Please Login or Register  to view this content.
    I would like the protected double click cell to do nothing if its double clicked by mistake when protected.

    I put your code in but it comes up with a syntax error

    Thanks again

    Dan

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: How to prevent double click event working on a protected cell

    There should not be a "]" at the end of the line, that was a typo. I removed it in my post.

    Please attach your file. I am still not getting your description. You first said the cell is unlocked on a protected sheet. Then you say you "enter [your] password to protect certain cells," which I can't understand. You don't need to enter a password to lock cells, and if the sheet is already protected I can't figure out how you would be entering a password.

  5. #5
    Forum Contributor
    Join Date
    10-25-2016
    Location
    Derby, England
    MS-Off Ver
    MS 2013
    Posts
    228

    Re: How to prevent double click event working on a protected cell

    Hi Jeff,

    Sorry I'm not describing this very well to you.

    I have 14 columns on my worksheet and I only need to enter into 9 of them. So 5 are always locked and protected.

    Once a shift (Day and Nights) I enter details into the 9 columns and on the last column I enter into which is column L, a userform triggers and asks for my initials and password which then locks the 14 columns. Thinking about it I could change the code to do just the unlocked cells but it works.

    What I'm trying to say is column C is one of the columns that is unlocked and not protected at the start of the shift. Once I fill out the other cells in that row, I save my file via the userform and then that locks the 14 cells.

    When I then double click on cell C again after its been locked and protected, that's when it comes up with the 1004 run time error.

    I appreciated your help on this Jeff

    Kind Regards
    Dan
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Before double click event with if statements (Double clicking blank cell stops bdc firing)
    By camdenpars in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-27-2014, 09:03 AM
  2. Click v double click event code
    By Greg J in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2014, 04:08 AM
  3. Double Click Event Range Cell
    By edgaryp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-03-2013, 09:19 AM
  4. Run an Add in with a double click event on cell
    By rachel.dudley in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2013, 10:02 AM
  5. [SOLVED] Double Click Cell to go to Source not working
    By john60 in forum Excel General
    Replies: 5
    Last Post: 11-29-2012, 07:00 AM
  6. Prevent ListBox Click Event Until Mouse Click
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2011, 12:23 PM
  7. userform label double-click goes to click event
    By John Paul Fullerton in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-19-2006, 01:00 PM

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