+ Reply to Thread
Results 1 to 7 of 7

Add vba code to lock cells on data entry

  1. #1
    Registered User
    Join Date
    10-03-2014
    Location
    Laguna, Philippines
    MS-Off Ver
    2013
    Posts
    5

    Add vba code to lock cells on data entry

    Hello!

    I found this vb http://www.ozgrid.com/VBA/auto-add-date.htm that timestamps in column E of my worksheet when a selection is made from the dropdown lists in column C. I just need some help in modifying this vb code so it locks the cells after each data entry and autosave it.

    Thank you!

    Timetoshine

  2. #2
    Forum Contributor Cerbera's Avatar
    Join Date
    07-06-2010
    Location
    Rotorua, New Zealand
    MS-Off Ver
    Excel 2007, 2013, 2016 & 365
    Posts
    137

    Re: Add vba code to lock cells on data entry

    Hi there,

    Cells are locked by default. To prevent editing you then have to protect the sheet (something like):

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-03-2014
    Location
    Laguna, Philippines
    MS-Off Ver
    2013
    Posts
    5

    Re: Add vba code to lock cells on data entry

    Thanks for your response Cerbera. However, I do not know where to insert that in the code since I have no knowledge in vb. Would appreciate if you could show me. Below is what is currently in my worksheet:

    Please Login or Register  to view this content.
    Also, the cells are left unlocked until an entry is made so the user can click the dropdown and make a selection and it simultaneously stamps the time in the next cell.


    Thank you!

    Timetoshine
    Last edited by timetoshine; 10-08-2014 at 08:46 AM.

  4. #4
    Forum Contributor Cerbera's Avatar
    Join Date
    07-06-2010
    Location
    Rotorua, New Zealand
    MS-Off Ver
    Excel 2007, 2013, 2016 & 365
    Posts
    137

    Re: Add vba code to lock cells on data entry

    Hi Timetoshine,

    Is it the cell that has been modified that you want to be locked or the timestamp cell? (Or both?)

    cheers,

    Cerbera

  5. #5
    Registered User
    Join Date
    10-03-2014
    Location
    Laguna, Philippines
    MS-Off Ver
    2013
    Posts
    5

    Re: Add vba code to lock cells on data entry

    Both. Thank you!

  6. #6
    Forum Contributor Cerbera's Avatar
    Join Date
    07-06-2010
    Location
    Rotorua, New Zealand
    MS-Off Ver
    Excel 2007, 2013, 2016 & 365
    Posts
    137

    Re: Add vba code to lock cells on data entry

    Hi Timetoshine,

    This code locks the cells.

    To do so however, it has to un-protect the sheet first, lock the cells then re-protect it.

    If you use a password you'll have to add:

    Please Login or Register  to view this content.
    At the end of the protect and unprotect lines of code.

    Please Login or Register  to view this content.
    If this works and you're happy can you close the thread under thread tools and click on the * Add Reputation on my post if you are happy to do so?

    Cheers,

    Cerbera
    If I've helped please click on *Add Reputation

  7. #7
    Registered User
    Join Date
    10-03-2014
    Location
    Laguna, Philippines
    MS-Off Ver
    2013
    Posts
    5

    Re: Add vba code to lock cells on data entry

    Thanks much Cerbera!

+ 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
    By DixieLou in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-01-2014, 03:39 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. lock cells after data entry
    By aleenkhan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-06-2012, 03:14 AM
  4. 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
  5. Code to lock a cell after data entry
    By MGT2000 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2008, 03:41 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