+ Reply to Thread
Results 1 to 8 of 8

How to populate a static date and time using a formula

  1. #1
    Forum Contributor
    Join Date
    05-29-2012
    Location
    Walnut, Ca
    MS-Off Ver
    Excel 2010
    Posts
    182

    How to populate a static date and time using a formula

    Can anyone tell me what type of vba code I could use to populate a static date and time that I could plug into a formula. Basically what I need is:

    IF A1<>"" then L1 shows the date and time of the entry. If A1="" then L1 remains blank. I don't want the date to change once it has been entered.

    Any suggestions.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,918

    Re: How to populate a static date and time using a formula

    Please Login or Register  to view this content.
    Ben Van Johnson

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

    Re: How to populate a static date and time using a formula

    You could use a VBA event macro:

    Please Login or Register  to view this content.

    Because it is worksheet code, it is very easy to install and automatic to use:
    1. right-click the tab name near the bottom of the Excel window
    2. select View Code - this brings up a VBE window
    3. paste the stuff in and close the VBE window
    If you have any concerns, first try it on a trial worksheet.

    If you save the workbook, the macro will be saved with it.


    To remove the macro:
    1. bring up the VBE windows as above
    2. clear the code out
    3. close the VBE window
    To learn more about macros in general, see:

    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    To learn more about Event Macros (worksheet code), see:

    http://www.mvps.org/dmcritchie/excel/event.htm

    Macros must be enabled for this to work!
    Gary's Student

  4. #4
    Forum Contributor
    Join Date
    05-29-2012
    Location
    Walnut, Ca
    MS-Off Ver
    Excel 2010
    Posts
    182

    Re: How to populate a static date and time using a formula

    I copied the code and pasted it but when I enter data in column A, the date doesn't populate in column L. Any suggestions?

  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: How to populate a static date and time using a formula

    The code only works for the first cell in column A (A1)

  6. #6
    Registered User
    Join Date
    10-25-2012
    Location
    New Delhi
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: How to populate a static date and time using a formula

    Hi,

    I used above VBA code. date and time are populating but not static.

    Please suggest

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

    Re: How to populate a static date and time using a formula

    I don't know.

  8. #8
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: How to populate a static date and time using a formula

    @HarishCSharma,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    HTH
    Regards, Jeff

+ 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