![]() |
How preserve the value of NOW() or TODAY()?
I like to write code to preserve the value of NOW() or TODAY().
When user opens the workbook the first time current system date + 30 day should be recorded and it should not change with subsequent openings of the workbook. I can do that manually inserting TODAY() into A1 then copy/paste special/values only to B1. Then make C1 = B1 + 30 How to do it in an efficinet macro. I know that I can use Range("A1").Copy Range("B1") but this copies the formula not just the value. |
How preserve the value of NOW() or TODAY()?
With Range("B1")
.Formula = Range("A1").Value + 30 .Numberformat = "mm/dd/yyyy" End With -- Regards, Tom Ogilvy "Nathan Gutman" wrote in message ... I like to write code to preserve the value of NOW() or TODAY(). When user opens the workbook the first time current system date + 30 day should be recorded and it should not change with subsequent openings of the workbook. I can do that manually inserting TODAY() into A1 then copy/paste special/values only to B1. Then make C1 = B1 + 30 How to do it in an efficinet macro. I know that I can use Range("A1").Copy Range("B1") but this copies the formula not just the value. |
How preserve the value of NOW() or TODAY()?
or just
With Range("B1") .Value = Date + 30 .Numberformat = "mm/dd/yyyy" End With -- Regards, Tom Ogilvy "Nathan Gutman" wrote in message ... I like to write code to preserve the value of NOW() or TODAY(). When user opens the workbook the first time current system date + 30 day should be recorded and it should not change with subsequent openings of the workbook. I can do that manually inserting TODAY() into A1 then copy/paste special/values only to B1. Then make C1 = B1 + 30 How to do it in an efficinet macro. I know that I can use Range("A1").Copy Range("B1") but this copies the formula not just the value. |
How preserve the value of NOW() or TODAY()?
Thanks Tom, both seem to be working.
Where and how did you learn how to do thigns like that? On Wed, 10 Dec 2003 12:32:57 -0500, "Tom Ogilvy" wrote: or just With Range("B1") .Value = Date + 30 .Numberformat = "mm/dd/yyyy" End With |
How preserve the value of NOW() or TODAY()?
Thanks Tom, both seem to be working.
Where and how did you learn how to do things like that? On Wed, 10 Dec 2003 12:32:57 -0500, "Tom Ogilvy" wrote: or just With Range("B1") .Value = Date + 30 .Numberformat = "mm/dd/yyyy" End With |
How preserve the value of NOW() or TODAY()?
Hi Tom,
In the second example how does the code know that Date is the value of Today() from A1? On Wed, 10 Dec 2003 12:32:57 -0500, "Tom Ogilvy" wrote: With Range("B1") .Value = Date + 30 .Numberformat = "mm/dd/yyyy" End With |
How preserve the value of NOW() or TODAY()?
It doesn't. Date is the VBA equipvalent of the worksheet function =today().
I was suggesting that there was no reason to store a date in A1 if the only purpose was to use it as a reference for advancing 30 days. -- Regards, Tom Ogilvy Nathan Gutman wrote in message ... Hi Tom, In the second example how does the code know that Date is the value of Today() from A1? On Wed, 10 Dec 2003 12:32:57 -0500, "Tom Ogilvy" wrote: With Range("B1") .Value = Date + 30 .Numberformat = "mm/dd/yyyy" End With |
All times are GMT +1. The time now is 02:20 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com