+ Reply to Thread
Results 1 to 4 of 4

Lock cells in Excel - activity only allowed using Userform

  1. #1
    Registered User
    Join Date
    09-07-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    8

    Lock cells in Excel - activity only allowed using Userform

    Hi all,
    I have created a userform with multiple Comboboxes and textboxes that captures data onto a spreadsheet.
    I would like to Lock the spreadsheet becuase people manually bypassing the userform.

    I know where to Lock all the fields in the spreadsheet by Protecting it, however the problem that I am facing with is if I do this then the Userform can also not update the spreadsheet.

    I hope this make sense.

    Please help.

    Thank you

  2. #2
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Lock cells in Excel - activity only allowed using Userform

    An elegant solution would be to:

    a. protect the specific worksheet against manual updates with a password;

    b. add the following code to the workbook_open event routine
    Please Login or Register  to view this content.
    the above line of code will keep your worksheet protected but will allow all VBA code to update the worksheet as if it was not locked

    c. protect your VBA code from being viewed (project properties)
    If you like my contribution click the star icon!

  3. #3
    Registered User
    Join Date
    09-07-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Lock cells in Excel - activity only allowed using Userform

    Hi OllieB,
    Thank you for the post.
    I have done option a but that also blocks the VB from entrering anything

    I have done option b but got an error

    I am using office 2010.

    Compile error.PNG

    Sorry..Still a newby at this ...Thank you for the help.

  4. #4
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Lock cells in Excel - activity only allowed using Userform

    Ji Pierrejza,

    You cannot just put the statement on its own in a module. It needs to be part of a routine, see below

    Please Login or Register  to view this content.
    You will also need to change the "password" with the actual password value (case sensitive) and change "Sheet1" into the actual name of the worksheet. Finally you will need to close and re-open the workbook for this statement to be executed.

+ 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] To Lock Excel Worksheets and only allows Update/Add entry via Userform
    By waihar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-19-2013, 02:38 AM
  2. [SOLVED] Excel vba userform - lock userform in place
    By PANTECH in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-30-2013, 10:30 AM
  3. Excel userform - Right Click Menu Num Lock?
    By revenge4ash8 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-26-2012, 07:37 AM
  4. calling sub from another userform not allowed, even after making it public
    By scadaman29325 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-14-2008, 09:28 AM
  5. Pressing CAPS LOCK show me Activity Panel
    By mi00mf in forum Excel General
    Replies: 0
    Last Post: 11-18-2005, 12:30 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