+ Reply to Thread
Results 1 to 18 of 18

Lock All Cells after data entry of a specific cell

  1. #1
    Registered User
    Join Date
    10-29-2012
    Location
    Birmingham, Alabama
    MS-Off Ver
    Excel 2010
    Posts
    11

    Lock All Cells after data entry of a specific cell

    Hello.
    I'm new to VBA/macros. Is it possible to lock all cells if a specific cell is not filled in by using a password? And then unlocking the sheet once entry has been done? I'm working on a project that has 10 sections and a management code needs to be entered after completion of each section before allowing data entry user to continue.

    Thanks for your help in advance!

  2. #2
    Valued Forum Contributor
    Join Date
    03-17-2012
    Location
    Warsaw, Poland
    MS-Off Ver
    2007/2010
    Posts
    555

    Re: Lock All Cells after data entry of a specific cell

    Please Login or Register  to view this content.
    Execute the macro on Workbook_Open as well since there won't be any change @ first.

    NINJA EDIT: I forgot to mention, that Cell "A1" has to be unlocked ofc.
    Last edited by Bishonen; 10-29-2012 at 12:20 PM.
    If you think that my answer was helpful, please click on the "Add to this user's Reputation" button.

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Lock All Cells after data entry of a specific cell

    Hello celialynn,

    Welcome to the Forum.

    Another way without VBA Code is demonstrated in the attached WorkBook. Try it.

    Also see the "Please consider" note at the bottom of this post.
    Attached Files Attached Files
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Lock All Cells after data entry of a specific cell

    Hello celialynn,

    I assume that you liked the alternative solution to your issue.

    Glad I could help in some way.

    Thank you for the Rep.

  5. #5
    Registered User
    Join Date
    10-29-2012
    Location
    Birmingham, Alabama
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Lock All Cells after data entry of a specific cell

    I'm still having an issue. I can't protect other cells & use the password protect not to allow users to go forward. I have attached a dummy sheet hoping someone could help. Normally there will be 10 sections to each worksheet that will require approval. I thought if I hid the rows from each section until the approval was given that would work but I can't seem to find the right macor or code to do that. Any help would be appreciated.
    Attached Files Attached Files
    Last edited by celialynn; 10-31-2012 at 03:40 PM.

  6. #6
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Lock All Cells after data entry of a specific cell

    Hello celialynn,

    Please see if the attached WorkBook is what you want.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    10-29-2012
    Location
    Birmingham, Alabama
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Lock All Cells after data entry of a specific cell

    Amazing! Thank you so much! That's exactly what I wanted to do. So for each section I would you the same code but alter the range?

  8. #8
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Lock All Cells after data entry of a specific cell

    Hello celialynn,

    .....the same code but alter the range?
    Yes. You got it now.

    Happy Coding!

  9. #9
    Registered User
    Join Date
    10-29-2012
    Location
    Birmingham, Alabama
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Lock All Cells after data entry of a specific cell

    Thank you for your help!

  10. #10
    Registered User
    Join Date
    10-29-2012
    Location
    Birmingham, Alabama
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Lock All Cells after data entry of a specific cell

    For some reason, when the data is entered into the cell it opens the correct rows, but sends the cursor to the beginning of the worksheet. I'm not sure if did it correctly. Any suggestions or direction for me to go would be appreciated!

    Here is what I did:
    Please Login or Register  to view this content.
    Last edited by celialynn; 11-01-2012 at 09:26 AM.

  11. #11
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Lock All Cells after data entry of a specific cell

    Hello celialynn,

    First of all, please do wrap your code, as stipulated in the Forum Rules, as I have done below.


    Please Login or Register  to view this content.
    Check for other Code somewhere else which might select the beginning of the Sheet. It could be in the Private Sub Worksheet_SelectionChange Event.

  12. #12
    Registered User
    Join Date
    10-29-2012
    Location
    Birmingham, Alabama
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Lock All Cells after data entry of a specific cell

    I checked and there isn't anything else. Is it possible after each section is unhidden to direct the cursor to an exact cell?

  13. #13
    Registered User
    Join Date
    10-29-2012
    Location
    Birmingham, Alabama
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Lock All Cells after data entry of a specific cell

    I found and it worked for me.
    Please Login or Register  to view this content.
    However, now I need to add my password to the protect portion of the code and i'm getting an error. Any suggestions? Thanks!

  14. #14
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Lock All Cells after data entry of a specific cell

    Hello celialynn,

    Please show me what you have done to "Protect" within the portion of your code, so that I can help you getting rid of the error message.

  15. #15
    Registered User
    Join Date
    10-29-2012
    Location
    Birmingham, Alabama
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Lock All Cells after data entry of a specific cell

    This is what I started with:

    Please Login or Register  to view this content.
    I received an error message: Compile error: variable not defined.

  16. #16
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Lock All Cells after data entry of a specific cell

    See the changes below where I have added Option Explicit and removed the word "Password"

    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    10-29-2012
    Location
    Birmingham, Alabama
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Lock All Cells after data entry of a specific cell

    Hello Again, Winon,
    I have run into another problem. When I enter data it automatically takes the cursor back to the last cell referenced in the application goto reference. Is there a way to stop looping?

    Please Login or Register  to view this content.
    Last edited by celialynn; 11-08-2012 at 05:29 PM.

  18. #18
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Lock All Cells after data entry of a specific cell

    Hello celialynn,

    Just remove this line from wherever it appears in your Code:

    Please Login or Register  to view this content.

+ 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