Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default 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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default 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




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default 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


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I Preserve Borders? BeetleBailey Excel Discussion (Misc queries) 10 June 24th 07 07:59 PM
IF TODAY equals date in cell A10, or if TODAY is beyond that date SoupNazi Excel Worksheet Functions 4 April 23rd 07 01:14 AM
Preserve format Str8 Excel Discussion (Misc queries) 3 March 31st 06 04:40 PM
Preserve settings Bampah Excel Discussion (Misc queries) 3 March 6th 06 04:58 PM
=IF(OR(TODAY()G9),"Pass","Overdue") Why doe it not wo. Fkor Excel Discussion (Misc queries) 3 March 10th 05 08:29 AM


All times are GMT +1. The time now is 02:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"