+ Reply to Thread
Results 1 to 5 of 5

Populate cell with current date and time, then lock cell

  1. #1
    Registered User
    Join Date
    12-13-2012
    Location
    calgary
    MS-Off Ver
    Excel 2007
    Posts
    2

    Question Populate cell with current date and time, then lock cell

    Hello,

    I'm fairly novice to excel. I've been looking for a solution to my problem and haven't been able to find anything specific enough (that I can recognize).

    I'm trying to have column A populate with the current date and time (i.e. NOW) when data is entered in column B, then have that cell lock so the date and time cannot be manually changed and it will not update if the data in column B is changed.

    Thank you in advance...

  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: Populate cell with current date and time, then lock cell

    You cannot do that with a NOW() formula, obviously, I assume that's why you're posting in the VBA forum.

    So you want a macro to insert a date into column A anytime you start to fill out a data row, and once the date is entered, it cannot be changed.

    1) Obviously you lock column A and protect the sheet. The keeps the users out of column A.
    2) This event macro in the sheet module will enter a date in column A:

    Please Login or Register  to view this content.
    _________________
    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
    Registered User
    Join Date
    12-13-2012
    Location
    calgary
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Populate cell with current date and time, then lock cell

    Thank you for the information. It is very useful.

    My apologies... I forgot to mention that I also want to share the workbook so more than one user can work in it at the same time. Is it possible to run a macro in a shared workbook? If not, is there another way this can be accomplished?

  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: Populate cell with current date and time, then lock cell

    I don't do any of that, chaotic work environment so we don't employ anything like that in our offices. Sorry. That's a separate question for a separate thread.

    If that takes care of your original query, please select Thread Tools from the menu above and mark the thread as solved. Thanks.

  5. #5
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Populate cell with current date and time, then lock cell

    You can do this if you allow iterative calculations:

    Excel Options > Formulas > Enable Iterative Calculation and pick at least once.

    Then In A1 enter:

    =IF(B1="","",IF(A1="",NOW(),A1)) and format A1 as mm/dd/yyyy hh:mm:ss
    Gary's Student

+ 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