+ Reply to Thread
Results 1 to 8 of 8

Auto Lock Cells After Data Entry

  1. #1
    Registered User
    Join Date
    03-31-2014
    Location
    Wisconsin
    MS-Off Ver
    Excel 2016
    Posts
    20

    Auto Lock Cells After Data Entry

    Test Doc.xlsm

    I have read thru several threads regarding using a VBA code to automatically lock a cell after data has been entered. I have not had any success with copying the code provided into my spreadsheet and making it work so I am posting in the hopes that I can get some help. I am not familiar with using VBA codes so please write your response in layman's terms.

    At my job we are trying to stop printing out so many documents and are starting to change over to more documents being completed electronically. Every document will have different fields that need to be completed and most will have multiple users. Like other people that have posted this question, I need to prevent User B from changing User A's input. I have attached a sample document that we use and that I have tried to apply a VBA code to.

    My assumption is that I start by unlocking the fields that need to be completed & then protecting the sheet. From what I have read, after that the VBA code would take over & lock the cells as data is entered. If this is correct, I have not been able to get it to work.

    Thanks in advance for the assistance

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Auto Lock Cells After Data Entry

    Hi DixieLou from Wisconsin. Welcome to the forum.

    It looks like you were 99% there. Your original code worked as is except on merged cells which you have in the Inspector column.

    The code below will work on merged and not-merged cells. Also, in your case, the two lines to EnableEvents are not needed as the code doesn't change a cell's value. And I replaced the IF statement, but that was more a matter of programing style than of substance or function.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Auto Lock Cells After Data Entry

    Deleted - AlphaFrog's answer much superior.
    Last edited by LJMetzger; 03-31-2014 at 08:46 PM. Reason: Deleted because AlphaFrog had much superior answer.

  4. #4
    Registered User
    Join Date
    03-31-2014
    Location
    Wisconsin
    MS-Off Ver
    Excel 2016
    Posts
    20

    Re: Auto Lock Cells After Data Entry

    Excellent! Thank you so much - this code worked!
    I did figure out that I need to get my worksheet set up first and then put in the VBA code. It didn't work if there was already data entered and then put in the code.

    Next time I have an Excel question I will come here first instead of spending loads of time trying to figure it out on my own.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Auto Lock Cells After Data Entry

    Quote Originally Posted by DixieLou View Post
    Excellent! Thank you so much - this code worked!
    I did figure out that I need to get my worksheet set up first and then put in the VBA code. It didn't work if there was already data entered and then put in the code.

    Next time I have an Excel question I will come here first instead of spending loads of time trying to figure it out on my own.
    You're welcome.

    Spending loads of time trying to figure it out was probably a good learning experience. You were really close to creating a final solution on your own. FYI: merged cells are a pain to deal with in VBA. I avoid using them as much as possible.

  6. #6
    Registered User
    Join Date
    02-27-2014
    Location
    Winnipeg, Canada
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Auto Lock Cells After Data Entry

    Is that code specific to the person whom asked the question or can i use that same code in my sheet?

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Auto Lock Cells After Data Entry

    Quote Originally Posted by Vdogeek View Post
    Is that code specific to the person whom asked the question or can i use that same code in my sheet?
    Both.

    Its not exclusive to anyone. Though I have no idea if it works for your sheet.

  8. #8
    Registered User
    Join Date
    02-27-2014
    Location
    Winnipeg, Canada
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Auto Lock Cells After Data Entry

    Tried it, no go. I'll play around with it some more. Thanks

+ 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. Auto lock cells after data entry when file is saved
    By greatwent in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-31-2014, 01:27 PM
  2. Macro to auto lock cells after data entry
    By Mhofu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-06-2013, 05:45 AM
  3. [SOLVED] Lock All Cells after data entry of a specific cell
    By celialynn in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 11-09-2012, 01:41 AM
  4. lock cells after data entry
    By aleenkhan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-06-2012, 03:14 AM
  5. Auto Lock Cells after Data Entry AND Save
    By ROSH22 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2012, 06:57 AM

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