Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Time Comparison

Greetings.

I've written a form that allows users to take a timestamp in
HH:mm:ss format and then insert it, in correct order, into a list
of other timestamps.

In order to insert the timestamp in its correct order, I loop
over the list until I find a value greater than the value of my
timestamp. I then insert a new row and place my timestamp
in the row I just created.

My problem is that I can't get my time comparison to work
properly. Here is how I attempt to do the comparison:

For i = 2 To LastRow
If CDate(EventTimer.EventClock.Value) CDate(Sheet2.Cells(i, 3).Value)
Then
Sheet2.Rows(i).Insert
Sheet2.Cells(i, 1) = i - 1
Sheet2.Cells(i, 3) = EventTimer.InputTime

'Increment places on the remaining rows.
For j = (i + 1) To (LastRow + 1)
Sheet2.Cells(j, 1) = j - 1
Next j
EventTimer.PlaceList.RowSource = EventTimer.PlaceList.RowSource
Exit Sub
End If
Next i

My row is always inserted at the top of the list, even though I know
the value entered into the EventClock field of the EventTimer form
is greater than the first item on the list.

Somehow the If statement where I compare the times just isn't
working.

What's wrong with my comparison? Do I need to bracket the times
with the # characters, as I've done before programming Acess?
Do I need to somehow better massage the contents of the EventClock
field or the Cells that I am comparing this against?

Respectfully,

Charles
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Time Comparison

How about this

i = Application.Match(EventTimer.EventClock.Value, Sheet2.Range("C2:C" &
lastrow), 1) + 1
Sheet2.Rows(i).Insert
Sheet2.Cells(i, 1) = i - 1
Sheet2.Cells(i, 3) = EventTimer.InputTime


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Charles in Iraq" wrote in message
...
Greetings.

I've written a form that allows users to take a timestamp in
HH:mm:ss format and then insert it, in correct order, into a list
of other timestamps.

In order to insert the timestamp in its correct order, I loop
over the list until I find a value greater than the value of my
timestamp. I then insert a new row and place my timestamp
in the row I just created.

My problem is that I can't get my time comparison to work
properly. Here is how I attempt to do the comparison:

For i = 2 To LastRow
If CDate(EventTimer.EventClock.Value) CDate(Sheet2.Cells(i,

3).Value)
Then
Sheet2.Rows(i).Insert
Sheet2.Cells(i, 1) = i - 1
Sheet2.Cells(i, 3) = EventTimer.InputTime

'Increment places on the remaining rows.
For j = (i + 1) To (LastRow + 1)
Sheet2.Cells(j, 1) = j - 1
Next j
EventTimer.PlaceList.RowSource = EventTimer.PlaceList.RowSource
Exit Sub
End If
Next i

My row is always inserted at the top of the list, even though I know
the value entered into the EventClock field of the EventTimer form
is greater than the first item on the list.

Somehow the If statement where I compare the times just isn't
working.

What's wrong with my comparison? Do I need to bracket the times
with the # characters, as I've done before programming Acess?
Do I need to somehow better massage the contents of the EventClock
field or the Cells that I am comparing this against?

Respectfully,

Charles



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
Comparison TiffQ23 Excel Discussion (Misc queries) 1 February 18th 09 08:24 PM
row comparison Jim Excel Worksheet Functions 4 August 21st 07 10:20 PM
Time comparison formula montagu Excel Discussion (Misc queries) 3 August 25th 05 03:37 PM
Time comparison Gixxer_J_97[_2_] Excel Programming 1 July 22nd 05 04:45 PM
Time/Data Comparison SharonP Charts and Charting in Excel 2 February 3rd 05 05:43 AM


All times are GMT +1. The time now is 02:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"