+ Reply to Thread
Results 1 to 11 of 11

Protecting cells - Input through a UserForm

  1. #1
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Protecting cells - Input through a UserForm

    Hi all,

    I was wondering whether there is a way of protecting cells/worksheet so that a user cannot input any information on a worksheet except through a userform?

    Thanks.
    Last edited by sgp; 11-12-2011 at 04:28 PM.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Protecting cells - Input through a UserForm

    Lock all the cells and protect the worksheet.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Protecting cells - Input through a UserForm

    Tried - but then the data from the Userform does not record on the worksheet, which makes sense why because I have protected the cells..is there are way where inputting data can only be done through UserForms. and not directly on the worksheets?

    Thanks.

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Protecting cells - Input through a UserForm

    Have a look at the Protect Method in the VBA help. You can set it with the UserInterfaceOnly option which means any changes made by VBA are allowed whilst preventing the user from modifying the worksheet.

    Note that you need to apply this protection each time the workbook is opened, see the remarks in the help topic.

    The other option is to just Unprotect and Protect your worksheet each time you want the code to make changes to it.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  5. #5
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Protecting cells - Input through a UserForm

    Hi Domski,

    Are you reffering to following link:
    http://www.exceltip.com/show_tip/Pro...Excel/337.html

    Thanks

  6. #6
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Protecting cells - Input through a UserForm

    Hi Domski

    The coding works but "Only cells with formulas are to be protected" with that code.

    The main cells I am trying to protect do not have formulas...is there anything else than could be done?

    Thanks.

  7. #7
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Protecting cells - Input through a UserForm

    hi,
    I think it's not the best way but I use
    (it's just an option)
    Please Login or Register  to view this content.
    and for example a commandbutton in a userform
    Please Login or Register  to view this content.
    Regards, John55
    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.

    ...enjoy -funny parrots-

  8. #8
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Protecting cells - Input through a UserForm

    Hi john55,

    Thanks for the code, seems to be working well.

    The only problem is that if I would like to make any changes, would I have to go into the codes and take them out?? Or can this be done through a password because when I enter the password it is not recognised. I have copied your code the way it is but I get the following msg:

    "The password you supplied is incorrect. Verify the CAPS LOCK key is off and be sure to use the correct capitalization".

    I am entering "1234" but I don't know why this error is occuring.

    Thanks.

  9. #9
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Protecting cells - Input through a UserForm

    hi
    I use this method to control the workbook( see the test file attached). depends what you want...just try to play with it.
    so, commandbutton4 contains something that you want to do in yr workbook but the code I suggested you unprotect, execute and then protect!
    then this is the button for unprotect
    Please Login or Register  to view this content.
    you can hide/unhide it using
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by john55; 11-12-2011 at 08:33 AM.

  10. #10
    Forum Contributor
    Join Date
    10-28-2011
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Protecting cells - Input through a UserForm

    Hi john55,
    Code seems to be working well, thanks for your help!

  11. #11
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Protecting cells - Input through a UserForm

    Glad it helped

+ 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