Help with a Time function or ... Something

M

Mike

Can some help me with a time funtion or idea. I have a workbook that I am
running a comparison between Sheet1 and Sheet2. I am comparing sheet1 columnP
with sheet2 columnP. If this matches I need to compare sheet1 colum F with
sheet2 column G. Colum F And Colum G are Time stamps.

I would like to be able to say if Colum F And Colum G are within 15 minutes
+ or -
then highlight that row.

Here is my code and i am already finding matches for ColumnP
For looper = 2 To lastToCheckRow
Set columnPcellPointer = xlWs.Cells(looper, 16)
For looper2 = 2 To lastToCheckRow2
Set columnPcellPointer2 = xlWs2.Cells(looper2, 16)
If columnPcellPointer = columnPcellPointer2 Then
If columnPcellPointer.Offset(0, -10).Value =
columnPcellPointer2.Offset(0, -10).Value Then
xlWs.Range("A" &
columnPcellPointer.Row).EntireRow.Interior.ColorIndex = 6
End If
End If
Next looper2
Next looper
 
G

Gary''s Student

Here is a function that will return true if two times are within 15 minutes
of each other:

Function within15(r1 As Range, r2 As Range) As Boolean
within15 = Abs(r1.Value - r2.Value) < 1.04166666666667E-02
End Function
 
M

Mike

Im getting an object required
For looper2 = 2 To lastToCheckRow2
Set columnPcellPointer2 = xlWs2.Cells(looper2, 16)
If columnPcellPointer = columnPcellPointer2 Then
If within15(columnPcellPointer.Offset(0, -9).Value,
columnPcellPointer2.Offset(0, -9).Value) Then
xlWs.Range("A" &
columnPcellPointer.Row).EntireRow.Interior.ColorIndex = 6
End If
End If
Next looper2
Next looper
 
G

Gary''s Student

Exactly... within15 needs ranges, not values as the arguments:

If within15(columnPcellPointer.Offset(0, -9), columnPcellPointer2.Offset(0,
-9)) Then
 
M

Mike

thanks gary has been a long day

Gary''s Student said:
Exactly... within15 needs ranges, not values as the arguments:

If within15(columnPcellPointer.Offset(0, -9), columnPcellPointer2.Offset(0,
-9)) Then
 

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