+ Reply to Thread
Results 1 to 4 of 4

Locking Column that has auto-populating dates from code

  1. #1
    Registered User
    Join Date
    01-15-2021
    Location
    CT
    MS-Off Ver
    2016
    Posts
    4

    Locking Column that has auto-populating dates from code

    Hello,

    I did a quick search but didn't really see anything so I apologize if this has already been asked.

    I have an Excel Spreadsheet where when data is entered into Cell B2, the current date and time is auto-populated in Cell A2 and so on down the sheet for example.


    I found this code that is letting me do this operation of having the date entered into Column A:

    Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo Handler
    If Target.Column = 2 And Target.Value <> "" Then
    Application.EnableEvents = False
    Target.Offset(0, -1) = Format(Now(), "dd-mm-yyyy hh:mm:ss")
    Application.EnableEvents = True

    End If

    Handler:

    End Sub


    I'm looking for assistance on making Column A to be locked so that the user can not manually enter a date, and the user can only start with Column B for entering data. Is there a way to make this happen?

    Thank you in advance.

  2. #2
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: Locking Column that has auto-populating dates from code

    Try this;
    Please Login or Register  to view this content.
    Remove "YourPW" if you do not want it password protected.

  3. #3
    Registered User
    Join Date
    01-15-2021
    Location
    CT
    MS-Off Ver
    2016
    Posts
    4

    Re: Locking Column that has auto-populating dates from code

    Hey Croweater.....Thank you for getting back and replying to my question.

    So I tried putting your suggested code in at the end of my code between Handler: and End Sub....it doesn't seem to let the date populate in Column A when I enter anything into the cells in Column B.

    I did remove the YourPW because its not intended to be password protected....just so a user can't type anything into column a like I said.

    Thanks.

    Any other suggestions?

  4. #4
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: Locking Column that has auto-populating dates from code

    Try putting this at the beginning of your change event..

    Please Login or Register  to view this content.
    and at the end;

    Please Login or Register  to view this content.
    Last edited by Croweater; 06-02-2021 at 09:37 PM.

+ 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. Combining auto-locking VBA code and auto-expanding a table
    By DixieLou in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-14-2019, 03:28 AM
  2. Calendar dates auto populating
    By Jamesraywebber85 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-06-2018, 08:43 AM
  3. [SOLVED] Auto populating Dates
    By AudreyKay in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-06-2015, 12:38 PM
  4. Auto Populating Calendar for Multiple Dates from Column Data
    By TrackingDates in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-18-2014, 03:39 PM
  5. Auto-populating a calendar with multiple dates
    By lamct in forum Excel General
    Replies: 2
    Last Post: 07-20-2013, 05:16 PM
  6. [SOLVED] Cell not auto-locking after auto-populating
    By Hillster in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-13-2012, 10:23 AM
  7. Auto Populating Dates Problems
    By img_jdawson in forum Excel General
    Replies: 1
    Last Post: 12-18-2010, 08:17 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