+ Reply to Thread
Results 1 to 15 of 15

Thread: function that enters the corrent date automatically

  1. #1
    Registered User
    Join Date
    09-02-2008
    Location
    Israel
    Posts
    4

    function that enters the corrent date automatically

    Hi all,

    I want to know if there is a function that enters the corrent date automatically. E.g., if I enter "3000" in B1, the result will be "2/9/2008" in, say, B2.

    Can it be done?

    xena

  2. #2
    Forum Contributor
    Join Date
    12-19-2006
    Posts
    100
    Hi Xena,
    "3000" in B1 - Why 3000?
    I don.t understand... Can you explain better what you want.

  3. #3
    Registered User
    Join Date
    09-02-2008
    Location
    Israel
    Posts
    4
    I want to make an expenses list so when I`ll write something today, never mind what, it will enter auto the date I entered this value.

    E.g., if i`ll write 3000$ in B2, B1 - that will be the date entered column - will be updtaed with the current date.

    Is it clear now?

  4. #4
    Forum Contributor
    Join Date
    12-19-2006
    Posts
    100
    You have any file?

  5. #5
    Forum Guru mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,984
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  6. #6
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,806
    heres a little snippet i saved from somwhere
    You can use a circular reference to enter the time when a change is made in
    another cell, then maintain that time. Choose Tools/Options/Calculation
    and check the Iteration checkbox. Then, if
    your target cell is A1 and you want the date/time to appear in B1, enter this in
    B1:

    =IF(A1="","",IF(B1="",NOW(),B1))

    Format B1 as you wish to display date, time, or both. If A1 is initially blank,
    B1 will return a null string (""). When a value is entered into A1, B1 will
    evaluate as "", therefore NOW() will be returned. After that (as long as A1
    remains populated), B1 will evaluate to a date/time and therefore will return
    the value in B1 - i.e., the date/time.

  7. #7
    Valued Forum Contributor
    Join Date
    08-26-2008
    Location
    singapore
    Posts
    618
    there are 2 suggestions:

    1. Remember this shortcut
    CTRL+; (semicolon)
    2. Attach your file and ask someone write a VBA code for you

  8. #8
    Registered User
    Join Date
    09-02-2008
    Location
    Israel
    Posts
    4
    Hi All,

    This one did the trick for me (From Paddy):
    1) Hit alt + F11 to get to the vb editor
    2) go insert | module
    3) paste in the following:

    Function DateAndTime()
    DateAndTime = Now
    End Function

    4) use it in a formula of the sort:

    =if(a1=100%,dateandtime(),"")

    One last thing: I`m a little newbie in advanced excel, so can anyone point me to some guide on this ctrl+F11 app? Didn`t know that.

    xena

  9. #9
    Forum Guru
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2003
    Posts
    2,288
    That's quite a roundabout way; why not just
    now()
    or
    today()

  10. #10
    Forum Guru
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2003
    Posts
    2,288
    i.e.
    =if(a1=1,today(),"")

  11. #11
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,806
    i suspect its becase the udf is not volatile (until you delete the contents ofreference cell)

  12. #12
    Registered User
    Join Date
    09-02-2008
    Location
    Israel
    Posts
    4
    I was wrong. I t`s not working, the paddy`s way. When I restart the excel file, it gives me "#name?" instead of date when a new number entered.

    Any suggestions?

  13. #13
    Forum Guru Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Do you want the date to remain static once entered (ie doesn't change)? If so, you really don't want to be entering this date with a formula. If you are happy using VBA then you could use a worksheet event to insert the date (as a static value rather than as a formula). Post back and I'm sure one of us can help you.

    Richard

  14. #14
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Cochrane,Alberta
    MS-Off Ver
    XL 2003,2007,2010
    Posts
    6,843
    so can anyone point me to some guide on this Alt+F11 app? Didn`t know that.
    Try to google " excel VBA for begginers "

    here's one site

    http://www.anthony-vba.kefra.com/vba/vbabasic1.htm

    If you are serious about learning VBA, than a book would work as well

  15. #15
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Cochrane,Alberta
    MS-Off Ver
    XL 2003,2007,2010
    Posts
    6,843
    Quote Originally Posted by xena08 View Post
    I was wrong. I t`s not working, the paddy`s way. When I restart the excel file, it gives me "#name?" instead of date when a new number entered.

    Any suggestions?
    The function
    Function DateAndTime()
    DateAndTime = Now
    End Function
    ...works well when you want to time stamp as the date will not change automatically as =now() or =today() does, it will only change when you enter the formula again.
    If you have the code saved in one workbook, and tried to use the function in another workbook, the function will not be recognized and the name error will show itself is this the case??

    Maybe creating an "addin" would work, then it would be available for all workbooks on your computer.

+ 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. Advanced Timesheet
    By DaKohlmeyer in forum Excel Programming
    Replies: 6
    Last Post: 07-28-2008, 04:49 PM
  2. Jump to todays date function.
    By Jazmania in forum Excel Worksheet Functions
    Replies: 8
    Last Post: 04-01-2008, 04:10 AM
  3. Replies: 1
    Last Post: 12-15-2007, 08:15 AM
  4. automatically add days to a date
    By jaspa in forum Excel General
    Replies: 1
    Last Post: 06-06-2007, 09:28 PM
  5. Date Function
    By jimmyjtn in forum Excel Worksheet Functions
    Replies: 2
    Last Post: 04-11-2007, 04:54 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.2.0