+ Reply to Thread
Results 1 to 7 of 7

Allowing user to select a cell but not edit it?

  1. #1
    Registered User
    Join Date
    05-07-2009
    Location
    Montreal
    MS-Off Ver
    Excel 2003
    Posts
    15

    Allowing user to select a cell but not edit it?

    My situation:

    I have an event handler that runs a procedure when a user double clicks a cell. This procedure modifies the contents of this cell and other cells. I want the user to be able to select the cell so they can double click it, but I don't want them to be able to single click it and modify it by hand (accidentally or not). Is there a way to lock/unlock the contents of the cell without locking the cell itself?
    Last edited by Falantar; 08-26-2009 at 09:19 AM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Allowing user to select a cell but not edit it?

    Your version of Excel allows you to enable selection of locked cells. Look at the options under Protection.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Allowing user to select a cell but not edit it?

    Try this:-
    Paste code at top of VB Window
    Please Login or Register  to view this content.
    Regards Mick

  4. #4
    Registered User
    Join Date
    05-07-2009
    Location
    Montreal
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Allowing user to select a cell but not edit it?

    Quote Originally Posted by shg View Post
    Your version of Excel allows you to enable selection of locked cells. Look at the options under Protection.
    Understood. However, I'm looking to avoid locked cells from being selected because this would only cause more problems. I'm not discounting it but I was hoping to find another way.

    @Mick - I don't quite understand what purpose those 2 subs serve. I added them but nothing has changed.

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Allowing user to select a cell but not edit it?

    I'm not certain what you are trying to accomplish but the following code will allow the user to access "locked cells" but not modify them.

    Add this code to your workbook open event:
    Please Login or Register  to view this content.
    The user will be allowed access to locked cells but not change them.

    Hope this helps.

    J
    Last edited by jaslake; 08-25-2009 at 09:35 PM. Reason: additional info
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  6. #6
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Allowing user to select a cell but not edit it?

    Hi,
    This code should be in the Worksheet Module. Right click sheet tab , Select "View Code", VB Window appears , Paste code into window (At top)
    If you make sure the Variable "temp" is at the top of the code Under "Option Explicit" (Which hopefully is at the top of your code page) then this variable is available to both the "Event Handlers".
    The Selection Event passes the Target value to the variable "Temp". The "Change Event" then Places the "Temp" value back in the Target cell, so that whatever you try to change the Target cell to, It will always be its original Value.
    Just an Idea, You'll probably need to restrict it to certain ranges.
    Regards Mick

  7. #7
    Registered User
    Join Date
    05-07-2009
    Location
    Montreal
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Allowing user to select a cell but not edit it?

    Thanks for the clarification Mick

    I have decided to just go with the basic protection and have written a workaround for my other event handlers. Thanks for the input

+ 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