Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Entering current date and time

I'm trying to come up with the quickest way to enter the current date and
time in my spreadsheet.

So far here's what I've tried:

Macro which recorded CTRL + ; (space) CRTL + SHIFT + ;
Unfortunately if you look at how the macro recorded this static date, it
actually has today's date listed in VB, not the actual function. I just want
VB to perform the FUNCTION.

I also tried the NOW() function, but I will have multiple rows keep track of
patches I've applied, and the date and time will change with each row entry.
The NOW formula updates all rows with the same date and time.

Any suggestions would be greatly appreciated.
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Entering current date and time

You could use something like:

Option Explicit
Sub PutDateTime()
On Error Resume Next
With Selection
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
.Value = Now
End With
If Err.Number < 0 Then
MsgBox "Time not inserted"
Err.Clear
End If
On Error Goto 0
End Sub

If you give it a nice shortcut combo, it might even be easier.

Tools|Macro|macros
select PutDateTime
click options
Change the shortcut key Uppercase T (maybe???)
When you type that uppercase T, the dialog will show
ctrl-shift-T
click ok
click cancel to dismiss the dialog

Try it out.

PrologPro wrote:

I'm trying to come up with the quickest way to enter the current date and
time in my spreadsheet.

So far here's what I've tried:

Macro which recorded CTRL + ; (space) CRTL + SHIFT + ;
Unfortunately if you look at how the macro recorded this static date, it
actually has today's date listed in VB, not the actual function. I just want
VB to perform the FUNCTION.

I also tried the NOW() function, but I will have multiple rows keep track of
patches I've applied, and the date and time will change with each row entry.
The NOW formula updates all rows with the same date and time.

Any suggestions would be greatly appreciated.
Thanks!


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Entering current date and time

Unfortunately that didn't work. When I run the macro, no value is entered.
I also need to make sure the date and time are static and automatically
entered with a macro (instead of entering today's date and time manually),
which is why I wanted to avoid the NOW formula.

I wish there were a way to record a macro or write VB for the "CTRL + ;"
shortcut...any ideas?

Thanks!

"Dave Peterson" wrote:

You could use something like:

Option Explicit
Sub PutDateTime()
On Error Resume Next
With Selection
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
.Value = Now
End With
If Err.Number < 0 Then
MsgBox "Time not inserted"
Err.Clear
End If
On Error Goto 0
End Sub

If you give it a nice shortcut combo, it might even be easier.

Tools|Macro|macros
select PutDateTime
click options
Change the shortcut key Uppercase T (maybe???)
When you type that uppercase T, the dialog will show
ctrl-shift-T
click ok
click cancel to dismiss the dialog

Try it out.

PrologPro wrote:

I'm trying to come up with the quickest way to enter the current date and
time in my spreadsheet.

So far here's what I've tried:

Macro which recorded CTRL + ; (space) CRTL + SHIFT + ;
Unfortunately if you look at how the macro recorded this static date, it
actually has today's date listed in VB, not the actual function. I just want
VB to perform the FUNCTION.

I also tried the NOW() function, but I will have multiple rows keep track of
patches I've applied, and the date and time will change with each row entry.
The NOW formula updates all rows with the same date and time.

Any suggestions would be greatly appreciated.
Thanks!


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Entering current date and time

Hi PrologPro,

Unfortunately that didn't work. When I run the macro, no value is
entered.


Dave's macro worked for me, inserting the current date and time in the
selected cell(s).

I also need to make sure the date and time are static and automatically
entered with a macro (instead of entering today's date and time manually),
which is why I wanted to avoid the NOW formula.


Dave's macro inserts a *statiic' snapshot date/time value.

I did not test Dave's shortcut suggestion, but I have no reason to assume
that this would not work perfectly.


---
Regards,
Norman



"PrologPro" wrote in message
...
Unfortunately that didn't work. When I run the macro, no value is
entered.
I also need to make sure the date and time are static and automatically
entered with a macro (instead of entering today's date and time manually),
which is why I wanted to avoid the NOW formula.

I wish there were a way to record a macro or write VB for the "CTRL + ;"
shortcut...any ideas?

Thanks!

"Dave Peterson" wrote:

You could use something like:

Option Explicit
Sub PutDateTime()
On Error Resume Next
With Selection
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
.Value = Now
End With
If Err.Number < 0 Then
MsgBox "Time not inserted"
Err.Clear
End If
On Error Goto 0
End Sub

If you give it a nice shortcut combo, it might even be easier.

Tools|Macro|macros
select PutDateTime
click options
Change the shortcut key Uppercase T (maybe???)
When you type that uppercase T, the dialog will show
ctrl-shift-T
click ok
click cancel to dismiss the dialog

Try it out.

PrologPro wrote:

I'm trying to come up with the quickest way to enter the current date
and
time in my spreadsheet.

So far here's what I've tried:

Macro which recorded CTRL + ; (space) CRTL + SHIFT + ;
Unfortunately if you look at how the macro recorded this static date,
it
actually has today's date listed in VB, not the actual function. I
just want
VB to perform the FUNCTION.

I also tried the NOW() function, but I will have multiple rows keep
track of
patches I've applied, and the date and time will change with each row
entry.
The NOW formula updates all rows with the same date and time.

Any suggestions would be greatly appreciated.
Thanks!


--

Dave Peterson



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Entering current date and time

A simple sendkeys command may do the trick.

Sub Macro1()
' use with the range statement to specify a location or without to place the
value in
'the activecell
Range("B25").Select

SendKeys "^{;}"

End Sub

hth

DMoney
--
EzMoney


"PrologPro" wrote:

I'm trying to come up with the quickest way to enter the current date and
time in my spreadsheet.

So far here's what I've tried:

Macro which recorded CTRL + ; (space) CRTL + SHIFT + ;
Unfortunately if you look at how the macro recorded this static date, it
actually has today's date listed in VB, not the actual function. I just want
VB to perform the FUNCTION.

I also tried the NOW() function, but I will have multiple rows keep track of
patches I've applied, and the date and time will change with each row entry.
The NOW formula updates all rows with the same date and time.

Any suggestions would be greatly appreciated.
Thanks!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Entering current date and time

How about?

Sub DateTime()
Selection.Value = Now
End Sub

Will enter the current date/time and does not change.
Stefan

PrologPro wrote:
I'm trying to come up with the quickest way to enter the current date and
time in my spreadsheet.

So far here's what I've tried:

Macro which recorded CTRL + ; (space) CRTL + SHIFT + ;
Unfortunately if you look at how the macro recorded this static date, it
actually has today's date listed in VB, not the actual function. I just want
VB to perform the FUNCTION.

I also tried the NOW() function, but I will have multiple rows keep track of
patches I've applied, and the date and time will change with each row entry.
The NOW formula updates all rows with the same date and time.

Any suggestions would be greatly appreciated.
Thanks!



--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200509/1
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Entering current date and time

What happened when you tried it?



PrologPro wrote:

Unfortunately that didn't work. When I run the macro, no value is entered.
I also need to make sure the date and time are static and automatically
entered with a macro (instead of entering today's date and time manually),
which is why I wanted to avoid the NOW formula.

I wish there were a way to record a macro or write VB for the "CTRL + ;"
shortcut...any ideas?

Thanks!

"Dave Peterson" wrote:

You could use something like:

Option Explicit
Sub PutDateTime()
On Error Resume Next
With Selection
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
.Value = Now
End With
If Err.Number < 0 Then
MsgBox "Time not inserted"
Err.Clear
End If
On Error Goto 0
End Sub

If you give it a nice shortcut combo, it might even be easier.

Tools|Macro|macros
select PutDateTime
click options
Change the shortcut key Uppercase T (maybe???)
When you type that uppercase T, the dialog will show
ctrl-shift-T
click ok
click cancel to dismiss the dialog

Try it out.

PrologPro wrote:

I'm trying to come up with the quickest way to enter the current date and
time in my spreadsheet.

So far here's what I've tried:

Macro which recorded CTRL + ; (space) CRTL + SHIFT + ;
Unfortunately if you look at how the macro recorded this static date, it
actually has today's date listed in VB, not the actual function. I just want
VB to perform the FUNCTION.

I also tried the NOW() function, but I will have multiple rows keep track of
patches I've applied, and the date and time will change with each row entry.
The NOW formula updates all rows with the same date and time.

Any suggestions would be greatly appreciated.
Thanks!


--

Dave Peterson


--

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
entering current time in shared work book - 2003 Radhakant Panigrahi Excel Discussion (Misc queries) 1 April 21st 10 07:32 PM
Any quick key for entering Current Date and Time? Philip Excel Worksheet Functions 2 January 12th 06 04:18 PM
Can I automatically enter the current date or current time into a Ben New Users to Excel 7 October 19th 05 03:38 PM
Entering static Date/Time GAMOSTEVE[_3_] Excel Programming 0 September 27th 04 04:49 PM
Current time Current date. yo beee Excel Programming 3 July 22nd 04 03:41 AM


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