Need Help With Entering Current Time

V

Vilius

I try to enter current time (Ctrl+Shift+;), but there are no seconds.
After i change cell to custom (hh:mm:ss), seconds are always equal to
00.

How can i fix this problem? I need just insert auto time WITH SECONDS.

Thanx in advance.
 
R

Rafael Ortiz

Hre is a way to do this:

Display Forms toolbar (View, Toolbars, Forms). Locate and click on the item
called Button. Now go to worksheet area, click where you want this button to
appear, then when Assign Macro box pops up, click on New. Then in the VBA
module that pops up, insert the following code BETWEEN the lines of code:

ActiveCell.Value = Application.WorksheetFunction.Text(Now(), "ss")

So the resulting code should look something like:

Sub Button1_Click()
ActiveCell.Value = Application.WorksheetFunction.Text(Now(), "ss")
End Sub

The button number may be slightly different. Now click in any cell, then
click the button.

If you want a key combination to execute this, then hit Alt + F8, click once
on your button macro, then click Options. Assign a letter, then close the
box. Now you will have a Ctrl + (whatever letter you selected) to display
the seconds.

MEO
 
D

Dave Peterson

I read this as you wanted to keep the hh:mm and wanted to add the non-zero
seconds.

Something like this would work:
Option Explicit
Sub CurTime()
With ActiveCell
.Value = Time
.NumberFormat = "hh:mm:ss"
End With
End Sub

If you put this in a workbook that's always open (personal.xla) and assign it a
shortcut key, it might work even better.
 
R

Rafael Ortiz

Sorry - I believe I did misread the question. To show hours, minutes,
seconds to the solution I provided should be easy to figure out - using my
same solution to use a button, just modify the code as follows:

Sub Button1_Click()
ActiveCell.Value = Application.WorksheetFunction.Text(Now(), "hh:mm:ss")
End Sub


MRO


Rafael Ortiz said:
Hre is a way to do this:

Display Forms toolbar (View, Toolbars, Forms). Locate and click on the item
called Button. Now go to worksheet area, click where you want this button to
appear, then when Assign Macro box pops up, click on New. Then in the VBA
module that pops up, insert the following code BETWEEN the lines of code:

ActiveCell.Value = Application.WorksheetFunction.Text(Now(), "ss")

So the resulting code should look something like:

Sub Button1_Click()
ActiveCell.Value = Application.WorksheetFunction.Text(Now(), "ss")
End Sub

The button number may be slightly different. Now click in any cell, then
click the button.

If you want a key combination to execute this, then hit Alt + F8, click once
on your button macro, then click Options. Assign a letter, then close the
box. Now you will have a Ctrl + (whatever letter you selected) to display
the seconds.

MEO
 
M

masim

have u tried using the now formula like this

=TEXT(NOW(),"hh:mm:ss")

this worked fine at my end.

Regards
Asim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top