Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA Code to add date


Excellent!

This works like I needed it to.

Now, 1 more question. Is it possible to set the sheet to automaticl
insert todays date when I save the document? Instead of having to clic
that button?

This is for an Invoice Template I am setting up.

Thanks


JMay Wrote:
Private Sub CommandButton1_Click()
Range("E11").Value = Format(Date, "mmmm dd,yyyy")
End Sub


"npereira" wrote in message
...

Hello all,

I am trying to find out what code to add to a command button t

insert
todays date formated as " October 17, 2004 " in Cell E 11.

Please let me know.

regards,

Nelson


--
npereira


------------------------------------------------------------------------
npereira's Profile:

http://www.excelforum.com/member.php...o&userid=10799
View this thread

http://www.excelforum.com/showthread...hreadid=269988


--
npereir
-----------------------------------------------------------------------
npereira's Profile: http://www.excelforum.com/member.php...fo&userid=1079
View this thread: http://www.excelforum.com/showthread.php?threadid=26998

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default VBA Code to add date

There's a workbook_beforesave event that you can tap into.

Rightclick on the excel icon to the left of the File dropdown on the worksheet
menubar.

Select view code and paste this in that codewindow.

Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
With Me.Worksheets("sheet1").Range("e11")
.Value = Date
.NumberFormat = "mmmm dd, yyyy"
End With
End Sub

Amend the worksheet name to what you want.



npereira wrote:

Excellent!

This works like I needed it to.

Now, 1 more question. Is it possible to set the sheet to automaticly
insert todays date when I save the document? Instead of having to click
that button?

This is for an Invoice Template I am setting up.

Thanks

JMay Wrote:
Private Sub CommandButton1_Click()
Range("E11").Value = Format(Date, "mmmm dd,yyyy")
End Sub


"npereira" wrote in message
...

Hello all,

I am trying to find out what code to add to a command button to

insert
todays date formated as " October 17, 2004 " in Cell E 11.

Please let me know.

regards,

Nelson


--
npereira

------------------------------------------------------------------------
npereira's Profile:

http://www.excelforum.com/member.php...o&userid=10799
View this thread:

http://www.excelforum.com/showthread...hreadid=269988


--
npereira
------------------------------------------------------------------------
npereira's Profile: http://www.excelforum.com/member.php...o&userid=10799
View this thread: http://www.excelforum.com/showthread...hreadid=269988


--

Dave Peterson

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
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Convert a julian gregorian date code into a regular date Robert Excel Worksheet Functions 3 June 13th 06 07:03 PM
VBA Code to add date npereira[_3_] Excel Programming 3 October 17th 04 10:35 PM
code to convert date from TEXT format (03-02) to DATE format (200203) Gauthier[_2_] Excel Programming 0 September 22nd 04 03:26 PM
code pasting a date changes date format in current month only Edward[_5_] Excel Programming 0 May 10th 04 06:13 PM


All times are GMT +1. The time now is 12:43 PM.

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

About Us

"It's about Microsoft Excel"