+ Reply to Thread
Results 1 to 14 of 14

Locking Cells after Entry

  1. #1
    Forum Contributor
    Join Date
    05-19-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    111

    Exclamation Locking Cells after Entry

    Hi
    In an excel sheet after we do entry in a cell, this value should be copied to another sheet and at the same time that cell should be locked and the operator should not be able to overwrite that cell with with any other values.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Locking Cells after Entry

    In the sheet module:

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 05-19-2010 at 10:37 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    05-19-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    111

    Re: Locking Cells after Entry

    Hi
    I tried the same, but its showing error
    Complie Error:
    Next without For.

    Also are these codes common for office 2003 and 2007?
    Last edited by faisal.ta; 05-19-2010 at 10:36 PM.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Locking Cells after Entry

    Code fixed above.

  5. #5
    Forum Contributor
    Join Date
    05-19-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    111

    Re: Locking Cells after Entry

    Thanks. its locking the cells now.
    But if we type in cell A1, then its getting copied in next sheet, but Cell A2 is also getting locked. What we need is Cell A1, after entering a value, we should not be able to edit in that cell where as Cell A2 and others must be open for editiong. Then after we enter a value in next cell, then it should get locked. and so on.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Locking Cells after Entry

    That's not what the macro does. It only copies the cell changed and locks the cell changed. I can't get the macro to do anything else than that.

  7. #7
    Forum Contributor
    Join Date
    05-19-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    111

    Re: Locking Cells after Entry

    OK, In that case can we make a clause that say Cell A1 to Cell A20, if the values are entered then it performs this action, Thats copy them to next sheet and then Lock the sheet. Only After Cell A1 to A20 is thru then it should perform this action

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Locking Cells after Entry

    This will perform the action only when one of the cells A1:A20 are changed.
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    05-19-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    111

    Re: Locking Cells after Entry

    Thanks for the help. But what i meant was Cell A1 to A20 only after all these cells are entered with a value, then it should copy and lock the sheet.Like when we have some check clauses for factors in cell 1 to 20, then when all of them are checked, only then it should lock the sheet.

  10. #10
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Locking Cells after Entry

    Lock the whole sheet? Lock those cells? Is the sheet already protected or does this protect it for the first time?

  11. #11
    Forum Contributor
    Join Date
    05-19-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    111

    Re: Locking Cells after Entry

    It Should Lock the whole sheet.
    No the sheet is Open for editing, but after the entry in Cell A1 to A20, it should Protect the whole sheet.
    But All Cells A1 to A20 should be entered with a value, say Checked OK. So if all the cells A1 to A20 is checked OK then it should protect and lock the sheet. If any 1 of the cells between A1 to A20 then it should not protect and lock the sheet.

  12. #12
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Locking Cells after Entry

    Try this:
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    05-19-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    111

    Re: Locking Cells after Entry

    Thanks
    That really worked and thanks a lot.
    And one final question, the password for the same is blank now.
    Can we get some password, and can that be hidden in the VBA

  14. #14
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Locking Cells after Entry

    Just add a password to the protect command.
    Please Login or Register  to view this content.

    To hide the VBA from prying eyes, you'll have to right-click on the VBAProject in the VBAProject window and select VBAProject Properties...you can set a password on the Protection tab. The next time you open the workbook, you'll need the password to see the vba.

+ 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