Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro and Today's Date

I would like to insert a macro that when i click a specific set of keys it
insert todays date in the specified cell, how can i do that please

thank you
ant
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Macro and Today's Date

I would like to insert a macro that when i click a specific
set of keys it insert todays date in the specified cell, how
can i do that please


Excel already has this feature...

Ctrl + ; (Control Key plus Semi-Colon Key)

and if you add the Shift Key to that, it inserts the time...

Ctrl + Shift + ; (Control Key plus Shift plus Semi-Colon Key)

Rick
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Macro and Today's Date

You don't really need a macro for that.

Current date Select a cell and press CTRL+;

However, if you want a macro:

Sub insDate()
ActiveCell = Format(Now, "d/m/yyyy")
End Sub

"Antonius" wrote:

I would like to insert a macro that when i click a specific set of keys it
insert todays date in the specified cell, how can i do that please

thank you
ant

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Macro and Today's Date

Or, even more simply:

Public Sub insDate()
ActiveCell.Value = Date
End Sub

Using Format() to convert Now (which contains both date and time) to a
string, then having XL's parser interpret the string isn't necessary.
How the date is interpreted will depend on your system date settings
(e.g., Format(Date, "d/m/yyyy") on 7 August 2007 (resulting in
7/8/2007), will be interpreted as 8 July 2007 if your date settings are
set to standard US.

The displayed date format will depend on the cell's display format, not
the format you input it with.

If you want a particular format, you should change the cell's
..NumberFormat property, e.g.:

Public Sub insDate()
With ActiveCell
.Value = Date
.NumberFormat = "d/m/yyyy"
End With
End Sub


In article ,
JLGWhiz wrote:

You don't really need a macro for that.

Current date Select a cell and press CTRL+;

However, if you want a macro:

Sub insDate()
ActiveCell = Format(Now, "d/m/yyyy")
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro and Today's Date

thank you so much, but what if i want it to insert the date in a specified
cell i.e. D10 what shall i do



"JE McGimpsey" wrote:

Or, even more simply:

Public Sub insDate()
ActiveCell.Value = Date
End Sub

Using Format() to convert Now (which contains both date and time) to a
string, then having XL's parser interpret the string isn't necessary.
How the date is interpreted will depend on your system date settings
(e.g., Format(Date, "d/m/yyyy") on 7 August 2007 (resulting in
7/8/2007), will be interpreted as 8 July 2007 if your date settings are
set to standard US.

The displayed date format will depend on the cell's display format, not
the format you input it with.

If you want a particular format, you should change the cell's
..NumberFormat property, e.g.:

Public Sub insDate()
With ActiveCell
.Value = Date
.NumberFormat = "d/m/yyyy"
End With
End Sub


In article ,
JLGWhiz wrote:

You don't really need a macro for that.

Current date Select a cell and press CTRL+;

However, if you want a macro:

Sub insDate()
ActiveCell = Format(Now, "d/m/yyyy")
End Sub




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Macro and Today's Date

thank you so much, but what if i want it to insert the date in a specified
cell i.e. D10 what shall i do


Using JE McGimpsey's suggested subroutine framework...

Public Sub insDate()
Range("D10").Value = Date
End Sub

Rick

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
Macro to jump to today's date Victor Delta Excel Discussion (Misc queries) 9 July 4th 06 08:52 PM
set cell to today's date macro Colm O'Brien Excel Programming 3 May 28th 04 11:56 AM
A macro for the today's date...not the current date abxy[_18_] Excel Programming 7 February 8th 04 11:05 PM
Macro to filter on today's date Mike Boardman Excel Programming 2 October 3rd 03 01:49 AM
Macro to filter on today's date Mike B[_4_] Excel Programming 0 October 1st 03 09:17 AM


All times are GMT +1. The time now is 04:15 AM.

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"