+ Reply to Thread
Results 1 to 13 of 13

A time and Date Formula

  1. #1
    Forum Contributor
    Join Date
    02-13-2009
    Location
    Indiana
    MS-Off Ver
    Excel 2015
    Posts
    183

    A time and Date Formula

    Hello.
    Here is what I want to do.
    I have a centralized document that myself and my co-workers use. I would like to insert a date formula that upon opening the "Main" document displays the current date (that is no problem). The catch is, when myself or my co-workers make a change to that document, and "save as" I would like that date to stick (no longer display the current date, but the date in which it was "saved as").

    Ideas?
    Last edited by sinspawn56; 04-21-2009 at 03:57 PM.

  2. #2
    Forum Contributor
    Join Date
    01-13-2009
    Location
    Mumbai
    MS-Off Ver
    Excel 2003, 2007
    Posts
    168

    Re: A time and Date Formula

    You might have displayed the date using"=Now()".

    While saving the document you can copy the cell in which the date is displayed and Paste the value of that cell using Pastespecial property..

    Regards,
    Vaibhav

  3. #3
    Forum Contributor
    Join Date
    02-13-2009
    Location
    Indiana
    MS-Off Ver
    Excel 2015
    Posts
    183

    Re: A time and Date Formula

    I have contemplated converting the formula to its value, but I am trying to make it most simple for everyone. Some co-workers forget to do that, so I was trying to make it a no hassle type of thing.

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: A time and Date Formula

    Hmmm, do you always "Save As" thus the original document is more of a template? If so, we can put simple code in the workbook that will convert that cell formula (=TODAY()) to it's value. However, if someone resaves the template, you'll lose your formula.

    Edit: if you save your original file as a xlt (template), then there's less danger of people overwriting it.
    Last edited by ChemistB; 04-21-2009 at 02:38 PM.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Forum Contributor
    Join Date
    01-13-2009
    Location
    Mumbai
    MS-Off Ver
    Excel 2003, 2007
    Posts
    168

    Re: A time and Date Formula

    there could be other ways to do so.. but right now the most simplest one that comes to my mind is by using Macro..

    you can use the following code..

    Suppose the name of the sheet in which the date is stored is "abc"
    In VBA-->Microsoft Excel Objects-->ThisWorkbook, write the following code

    Please Login or Register  to view this content.
    Last edited by c.vaibhav; 04-21-2009 at 02:54 PM. Reason: Forgot to put code tags

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: A time and Date Formula

    c.vaibhav,

    Please take a few minutes to read the forum rules, and then edit your post to add code tags.
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Contributor
    Join Date
    02-13-2009
    Location
    Indiana
    MS-Off Ver
    Excel 2015
    Posts
    183

    Re: A time and Date Formula

    Quote Originally Posted by ChemistB View Post
    Hmmm, do you always "Save As" thus the original document is more of a template? If so, we can put simple code in the workbook that will convert that cell formula (=TODAY()) to it's value. However, if someone resaves the template, you'll lose your formula.

    Edit: if you save your original file as a xlt (template), then there's less danger of people overwriting it.
    I have not saved the document as a Template (xlt) but more or less it is a template. It is not to be overwritten only saved as.

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: A time and Date Formula

    You can paste this code (similar to c.vaibhav's) into the Workbook object of the VBA Editor. This is written assuming your "=TODAY()" formula is in sheet1 cell A1
    Please Login or Register  to view this content.
    Does this work for you?

  9. #9
    Forum Contributor
    Join Date
    02-13-2009
    Location
    Indiana
    MS-Off Ver
    Excel 2015
    Posts
    183

    Re: A time and Date Formula

    I found the workbook object but how do I go about pasting your code in there?


    EDIT* I found the object and pasted the code. But I am unable to save the template with the formula in there. I am having to go back into the template and redo the formula.
    Last edited by sinspawn56; 04-21-2009 at 03:45 PM.

  10. #10
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: A time and Date Formula

    The easiest way without having to go through manually opening up the VBA editor is to right click on the small Excel icon in the upper left of your spreadsheet next to the File dropdown menu. One of the options should be "View Code" Clicking on that will automatically put you into the "This workbook" code window in VBA. How's that?

  11. #11
    Forum Contributor
    Join Date
    02-13-2009
    Location
    Indiana
    MS-Off Ver
    Excel 2015
    Posts
    183

    Re: A time and Date Formula

    Ok, if the code is running before I save the document, how do I save the code into the workbook without it running and converting the formula to its value?

  12. #12
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: A time and Date Formula

    In order to make changes to the template, open it without enabling macros. So add your code, save the template, reopen the workbook but do not enable macros, then enter your formula again and resave it. Did that work?

  13. #13
    Forum Contributor
    Join Date
    02-13-2009
    Location
    Indiana
    MS-Off Ver
    Excel 2015
    Posts
    183

    Re: A time and Date Formula

    Yes, that works. Thank you both for all your help.

+ 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