Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sky Sky is offline
external usenet poster
 
Posts: 10
Default Command Button Date/Time Stamp

I am trying to date/time stamp a cell by clicking a command button. I want
the cell to display the date and time when the button was last clicked. I can
get it to display the date but I cannot figure out how to get "SendKeys" to
allow me to select CTL+; "SPACE" CTL+ALT+; . This is what I have now as a
command for the button and it will give me a date in the selected cell:

Private Sub CommandButton1_Click()
Range("c2").Select
SendKeys "^(;)"
End Sub
--
skyknight
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Command Button Date/Time Stamp

Hi Sky,

Try:

'=============
Private Sub CommandButton1_Click()
ActiveCell.Value = Format(Now, "mm/dd/yy hh-mm")
End Sub
'<<=============


---
Regards,
Norman



"sky" wrote in message
...
I am trying to date/time stamp a cell by clicking a command button. I want
the cell to display the date and time when the button was last clicked. I
can
get it to display the date but I cannot figure out how to get "SendKeys"
to
allow me to select CTL+; "SPACE" CTL+ALT+; . This is what I have now as a
command for the button and it will give me a date in the selected cell:

Private Sub CommandButton1_Click()
Range("c2").Select
SendKeys "^(;)"
End Sub
--
skyknight



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Command Button Date/Time Stamp

Private Sub CommandButton1_Click()
Range("c2").Value = Now()
End Sub

--
HTH...

Jim Thomlinson


"sky" wrote:

I am trying to date/time stamp a cell by clicking a command button. I want
the cell to display the date and time when the button was last clicked. I can
get it to display the date but I cannot figure out how to get "SendKeys" to
allow me to select CTL+; "SPACE" CTL+ALT+; . This is what I have now as a
command for the button and it will give me a date in the selected cell:

Private Sub CommandButton1_Click()
Range("c2").Select
SendKeys "^(;)"
End Sub
--
skyknight

  #4   Report Post  
Posted to microsoft.public.excel.programming
Sky Sky is offline
external usenet poster
 
Posts: 10
Default Command Button Date/Time Stamp

Thanks Guys
I finally also came up with my own less elegant one.
===========
Private Sub CommandButton1_Click()
Range("c2").Select
SendKeys "^(;)"
SendKeys " "
SendKeys "^+(;)", Wait
End Sub
=========
skyknight



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Command Button Date/Time Stamp

Hi Sky,

I finally also came up with my own less elegant one.


Elegance is in the eye of the beholder, but why use a clunky implementation
of SendKeys when a native function is available?

---
Regards,
Norman


"sky" wrote in message
...
Thanks Guys
I finally also came up with my own less elegant one.
===========
Private Sub CommandButton1_Click()
Range("c2").Select
SendKeys "^(;)"
SendKeys " "
SendKeys "^+(;)", Wait
End Sub
=========
skyknight





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
Can excel have a button to input (stamp) the systems date and/or . abe Excel Worksheet Functions 5 April 24th 07 10:00 PM
Date and time stamp, control button MattB Excel Discussion (Misc queries) 5 March 8th 07 08:35 PM
Create a button that will date stamp todays date in a cell Tom Meacham Excel Discussion (Misc queries) 3 January 11th 06 01:08 AM
How can i use a command button to validate date and time kcdonaldson Excel Discussion (Misc queries) 0 December 9th 05 04:03 PM
Date/Time Stamp Macro Button Problem jp_m8 Excel Programming 5 August 26th 04 07:33 PM


All times are GMT +1. The time now is 10:19 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"