Re: Inserting current time

Giganews Newsgroups
Subject: Re: Inserting current time
Posted by:  Nick Hodge (nick_hod…
Date: Mon, 13 Oct 2003


How about putting a CommandButton from the control toolbox on the worksheet.
(Right click anywhere on the toolbars and select the Control Toolbox.
Select a command button from this and draw it on the sheet.  While still in
design mode, right click the control and select 'properties'.  Set the
TakeFocusOnClick setting to 'false'.  Double click the control and paste the
code below in to the resultant window.  Close the window, exit 'design
mode', (click on the little set square icon))

Now each time you click on the button, it will put in the current time,
including seconds and advance to the cell below.


Private Sub CommandButton1_Click()
ActiveCell.Value = Time()
ActiveCell.Offset(1, 0).Select
End Sub

(oooohhhhhh, it was sooooooooooooo satisfying to use select!  (It is seldom
necessary to use select, you can act on objects in VBA without's just been such a long time!))

Nick Hodge
Southampton, England

"Talltone" <curete…> wrote in message
> I am trying to insert times into a Excel 2000 spreadsheet
> in the format hh:mm:ss.  Because a number of events have
> to be logged, some very close together, I am trying to use
> the CTRL + SHIFT + : (colon) technique.  I have formatted
> the cells to show hh:mm:ss but when I use the key
> combination above, it only gives me hh:mm.  When I press
> RETURN to move to the next cell the cell data then changes
> to hh:mm:00.
> In other words I cannot get it to record the seconds.
> Please can somebody help! I seem to be close to the
> solution but not close enough!  The computer clock shows
> seconds, by the way.



In response to

Inserting current time posted by Talltone on Mon, 13 Oct 2003