ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Behavior of Today()?? (https://www.excelbanter.com/excel-programming/308641-behavior-today.html)

BrianG[_4_]

Behavior of Today()??
 
I have a worksheet cell which uses the Today() function. A macro
controls other data entry, and printing functions for this worksheet. I
created this worksheet quite some time ago and now find myself needing
to duplicate most of the macro processes on a new worksheet. I've
basically copied this worksheet and modified the macro as needed. My
problem is that with the old worksheet, when a completed sheet is saved
then reopened, the cell that contained the Today() function is not
updated with the current date. That cells contents show the current
date instead of the function. With my new worksheet the Today()
function remains and the cell is updated with the current date, which I
don't want. I have been unable to find the difference in the code that
is causing this behavior. Can anyone point me where to look or explain
what might be going on?

BrianG



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Tom Ogilvy

Behavior of Today()??
 
ActiveCell.Formula = "=Today()"
ActiveCell.Value = ActiveCell.Value

or for the second line
activecell.copy
activecell.pastespecial xlvalues

both/all lines would work like the old sheet.

only the top line would work like the new sheet.

just a guess.

It could also be

oldsheet
ActiveCell.Formula = Date

new sheet
ActiveCell.Formula = "=Today()"

--
Regards,
Tom Ogilvy

"BrianG" wrote in message
...
I have a worksheet cell which uses the Today() function. A macro
controls other data entry, and printing functions for this worksheet. I
created this worksheet quite some time ago and now find myself needing
to duplicate most of the macro processes on a new worksheet. I've
basically copied this worksheet and modified the macro as needed. My
problem is that with the old worksheet, when a completed sheet is saved
then reopened, the cell that contained the Today() function is not
updated with the current date. That cells contents show the current
date instead of the function. With my new worksheet the Today()
function remains and the cell is updated with the current date, which I
don't want. I have been unable to find the difference in the code that
is causing this behavior. Can anyone point me where to look or explain
what might be going on?

BrianG



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




Bernie Deitrick

Behavior of Today()??
 
Brian,

Your code could have been:

1) directly writing the date to the cell
2) copying and pasting values for that cell
3) converting the cell to a value

Note that your code could include workbook events, such as the Before_Close
event.

If you need code to accomplish the same thing, you could simply use (if the
cell is, say, A1)

Worksheets("SheetName").Range("A1").Value = Date

HTH,
Bernie
MS Excel MVP

"BrianG" wrote in message
...
I have a worksheet cell which uses the Today() function. A macro
controls other data entry, and printing functions for this worksheet. I
created this worksheet quite some time ago and now find myself needing
to duplicate most of the macro processes on a new worksheet. I've
basically copied this worksheet and modified the macro as needed. My
problem is that with the old worksheet, when a completed sheet is saved
then reopened, the cell that contained the Today() function is not
updated with the current date. That cells contents show the current
date instead of the function. With my new worksheet the Today()
function remains and the cell is updated with the current date, which I
don't want. I have been unable to find the difference in the code that
is causing this behavior. Can anyone point me where to look or explain
what might be going on?

BrianG



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





All times are GMT +1. The time now is 11:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com