Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Function 1

Status
Not open for further replies.

max1565

Technical User
Dec 16, 2002
57
US
I use the following to enter a date in a cell:

worksheets("data").range("d12") = "=TODAY()"

It places the date okay, but instead of actually entering the date, it enters the formular. So tomorrow when the date changes, that cell changes to the new date. How do I enter the current date in the cell and prevent it from changing?

Thanks
 
thanks for your reply skip, but using "now" does the same thing. when the actual date changes, the date in the cell changes also. i want the date in the cell to stay the same after it has been entered.

thanks
 
Could you do a very long way round and use the now function in that cell. Copy the data and then PasteSpecial values only in the same cell. I know its long winded but it will probably give the result you want

dyarwood
 
try this then:
worksheets("data").range("d12").value = format(Now(),"dd/mm/yyyy")


Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Max,
Have you actually tried Skip's code? It works just fine, and adds the date as a constant value.


Rob
[flowerface]
 
Rob

At first I tried just using the function, but as you stated, I tried it exactly as suggested and it worked fine. However, I need a date without the time. Any suggestions?

Thanks
 
try my post

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
I don't understand what all the fuss is about. All you should need is:
[blue]
Code:
  If IsEmpty([D12]) Then [D12] = Date
[/color]

Where are you putting your code? Every time your code executes, the date will change. That is why you need to test to see whether a date (or something) is already in the cell before updating.
 
Hey max,

Date/Time is just a number like 37956.40738 which is 12/1/2003 9:46 AM here in Texas.

But with ONLY a format change (NO CHANGE TO THE NUMBER) I can display the same date/time as

Monday (dddd) or

Mon, December 1 2003 (ddd, mmmm d yyyy) or

9:45 Monday 1 Dec 03 (h:mm dddd d mmm yy)

:)


Skip,
Skip@TheOfficeExperts.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top