+ Reply to Thread
Results 1 to 3 of 3

Prevent direct editing, but allow userform to update cell

  1. #1
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Prevent direct editing, but allow userform to update cell

    Good day all,
    I have a shared spreadsheet which is currently being used by about 7 people. The spreadsheet tracks a growing list of records we obtain from another system, but will always be limited to a maximum of 15000 rows.

    Every day, I obtain a text file, which I import to the spreadsheet, and compare the existing data from the newly obtained. The macro appends anything new, and modifies records for those which are on both the spreadsheet and the text file. The users then review the new items (and some of the modified) and enter a value in column C.

    My issue is that my macro depends on consistent data entry in that column. I have it set up now so that when a user double clicks on any row in column C, they get a pop up userform with several options. They choose the option and click an OK button, and their value gets logged on the sheet.

    They all prefer this to using a combo box/drop down.

    The problem is, one of the people consistently enters her own data, then complains that the macro doesn't pick up her updates correctly.

    Is there an easy way to block such direct cell editing, while allowing the data from the userform to be applied? I think I could add something to the double click to unlock the cell, add the update, then relock it, but am not sure if that's the most efficient...

    Thanks!
    JP
    Last edited by JP Romano; 10-07-2011 at 05:09 PM. Reason: Solved

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Prevent direct editing, but allow userform to update cell

    JP,

    I would protect the sheet (have all cells locked) so that the only way to enter information is to double click and use the userform. The double-click event can be in the ThisWorkbook event module:
    Please Login or Register  to view this content.


    And then in the userform, you would have the sheets.unprotect in the initialize and the sheet.protect in the terminate events:
    Please Login or Register  to view this content.


    Alternatively, you could alter whatever userform sub actually enters the information (like a command button click) to have the sheet.unprotect at the beginning of its code and the sheet.protect at the end of its code so that the .unprotect and .protect isn't split up:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Re: Prevent direct editing, but allow userform to update cell

    Fantastic. Works like a charm. Much appreciated!

+ 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