Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way of recording event times in Excel 2

Status
Not open for further replies.

scorpio1948

Instructor
Jul 14, 2001
4
GB
Is there a way of recording a series of actual event times in Excel, if I enter a code in col A, I would like to pick up the system time and display it alongside the event

1 1:00:10
2 1:01:05
3 1:05:15
4 1:08:30
I then need to be able to use each the time value
 
Here is a start....

Right click on the sheet name and select view code,
in the 1st drop down labled (general) switch to workbook, then in the next drop down, switch to change.

then paste this code between the private sub and end sub statements....


'------------------------------------

Dim c As Integer
Dim r As Integer

c = ActiveCell.Column
r = ActiveCell.Row

If c <> 1 Then End
Cells(r - 1, c + 1) = Time$
Cells(r - 1, c + 1).NumberFormat = &quot;h:mm:ss AM/PM&quot;

 
Geeeze. I print this one off, and later this afternoon someone already answers it. On a Sunday even. Hat's off to ETID.

I have a feeling this has already been resolved by EDIT, but my approach was to create a macro button and assign the following code, so that when pressed, a counter and time value is entered in columns A & B. Just erase everything in columns A & B to start over, since you may want to post the events to another table for later analysis ?


Sub SetTimeOnClick()

CheckValue = Range(&quot;A1&quot;).Value
If CheckValue < 1 Then Range(&quot;A1&quot;).Select ' start on row 1 or if something's there just keep going

RowNum = Selection.Range(&quot;A1&quot;).Row ' Determine Row and Column number from active cell
ColumnNum = Selection.Range(&quot;A1&quot;).Column

ActiveSheet.Rows(RowNum).Columns(1) = RowNum ' Enter Counter
ActiveSheet.Rows(RowNum).Columns(2) = Now() ' Enter the right now time
ActiveSheet.Rows(RowNum).Columns(2).NumberFormat = &quot;h:mm:ss&quot; ' Format as time

SendKeys &quot;{Down}&quot;, True

End Sub
 
Probably a combination of both our responses would be the primo answer...I had trouble with the now() function changing all of the previous dates as well, when a new entry is made.
 
Someone gave me a file for conducting equipment time studies that did exactly what Scorpio1948 requested. I thought this will be an easy answer . . . but it was written in L123.

So I thought might as well give it a go.

Let's see what Scorpio1948 does with it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top