Vba non-volatile Date?

  • Hello!
    Please, i need non-volatile way to: When workbbook is opened, put today's date in cell F1, when i click on exit or close Excel, remove value from F1. But, without that Excel message "Do you want to save chan......".? Please, hellp.


    Basically, when workbook is active, show date in cell F1, when i close it, remove Date, to have it w/o exit message.



    So, my question is impossible. Unless, clicking excel message box on exit or, disabling auto calculate option. Originally, I needed today function to check date and display today's date, if not then blank cell.


    Code
    1. [Private Sub Workbook_BeforeClose(Cancel As Boolean)
    2. Worksheets("Sheet1").Range("F1").ClearContents
    3. ThisWorkbook.Saved = True
    4. End Sub


    Code is fine, BUT i lost Save message on other data, when i enter manually other cell values(on other sheets) i lost Save message on exit[Blocked Image: http://www.mrexcel.com/forum/images/smilies/frown.png]
    :?

  • Re: Vba non-volatile Date?


    Can't see the reason why you remove the date only to replace it next time the workbook is opened... Who's going to see it in the meantime?


    The only way I can think of to do this is to set the saved Flag to True when you add the date on workbook open (you didn't include the code for that). Then, when closing, check if the workbook has been changed before you blank the date. If it has been changed, then just blank the date and let the default message show. If it has not been changed, blank the date, set the Saved Flag to True and let the code continue.

  • Re: Vba non-volatile Date?


    Code
    1. Private Sub Workbook_BeforeClose(Cancel As Boolean)
    2. Worksheets("Sheet1").Range("F1").ClearContents
    3. ThisWorkbook.Save
    4. End Sub


    It doesn't need to be cleared from F1. I think my question is impossible, I have cell formula whoes referencing to F1 cell. So whatever value is in F1 that's still gonna change Excel workbbook state .


    And please, what Flags??? I don't understand, sorry for poor english

  • Re: Vba non-volatile Date?


    Quote

    Worksheets("Sheet1").Range("F1").ClearContents


    Quote

    It doesn't need to be cleared from F1


    I'm sorry - language barrier. I have no idea what you mean.

  • Re: Vba non-volatile Date?


    It does not need to be cleared from F1cell
    I think my question is impossible, I have cell formula whoes referencing to F1 cell. So whatever value is in F1 that's still gonna change Excel workbbook state .


    And please, what Flags??? I don't understand, sorry for poor English