Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I Preserve Borders? | Excel Discussion (Misc queries) | |||
IF TODAY equals date in cell A10, or if TODAY is beyond that date | Excel Worksheet Functions | |||
Preserve format | Excel Discussion (Misc queries) | |||
Preserve settings | Excel Discussion (Misc queries) | |||
=IF(OR(TODAY() |
Excel Discussion (Misc queries) |