View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
J.E. McGimpsey J.E. McGimpsey is offline
external usenet poster
 
Posts: 493
Default today code in vba

I'd think

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

would be more appropriate than using Now, or perhaps

With Worksheets("yoursheetname").Range("A1")
.NumberFormat = "m/d/yy"
.Value = Date
End With

In article ,
"John Wilson" wrote:

Mathew,

Private Sub CommandButton1_Click()
Worksheets("yoursheetname").Range("A1") = Now
End Sub

You can replace the "Now" with something like:
Format(Now, "m/d/yy")
or whatever format you'd like it to appear in.

By the way..."Today" can't be used in VBA

John

"MPB" wrote in message
...
Good evening all

I am after some simple code to apply to a CommandButton1_Click(),
where when the button is clicked, today's date is inserted into the active

cell.
(Though I do require this date to then be fixed, and not change the

following day)

Any help most appreciated.
Thank you
Mathew




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.551 / Virus Database: 343 - Release Date: 11/12/2003