JonRowland
Active Member
- Joined
- May 9, 2003
- Messages
- 415
- Office Version
- 365
- Platform
- Windows
Hi,
I'm running a loop to run through a series of rows in order to identify duplicate rows and then delete then.
So what the code will look for is a time within 2 seconds contained within row B.
If this is true then to check values in C & D are same. However values in C&D will only be unique for the last 10 digits so I thought the RIGHT function would be good to use but when running this bit of code I get a run-time error 424 "OBJECT REQUIRED"
<code>
Row = 2
LastRow = Cells.Find("*", Cells(1), xlFormulas, xlWhole, xlByRows, xlPrevious).Row
Do
Deleted = False
TIME1 = Cells(Row, 2)
TIME2 = Cells(Row + 1, 2)
DIFFERENCE12C = DateDiff("s", TIME1, TIME2)
Cells(Row, 1).Select
If DIFFERENCE12C <= 2 And DIFFERENCE12C >= -2 Then
cct1 = Right(Cells(Row, 3 + columnoffset), 10).Value
cct2 = Right(Cells(Row, 3 + columnoffset), 10).Value
rct1 = Right(Cells(Row, 4 + columnoffset), 10).Value
rct2 = Right(Cells(Row + 1, 4 + columnoffset), 10).Value
ez1 = Cells(Row + 1, 11)
If cct1 = cct2 And rct1 = rct2 Then
If ez1 > 0.5 Then
Cells(Row, 6).Value = "ez1"
End If
Rows(Row + 1).Delete
Deleted = True
Else
End If
End If
If Deleted = False Then Row = Row + 1
If Deleted = True Then LastRow = LastRow - 1
Loop Until Row > LastRow
</code>
I've read that I may need to use a SET statement but not sure what I need to do so any help would be welcome.
Thx
Jon
I'm running a loop to run through a series of rows in order to identify duplicate rows and then delete then.
So what the code will look for is a time within 2 seconds contained within row B.
If this is true then to check values in C & D are same. However values in C&D will only be unique for the last 10 digits so I thought the RIGHT function would be good to use but when running this bit of code I get a run-time error 424 "OBJECT REQUIRED"
<code>
Row = 2
LastRow = Cells.Find("*", Cells(1), xlFormulas, xlWhole, xlByRows, xlPrevious).Row
Do
Deleted = False
TIME1 = Cells(Row, 2)
TIME2 = Cells(Row + 1, 2)
DIFFERENCE12C = DateDiff("s", TIME1, TIME2)
Cells(Row, 1).Select
If DIFFERENCE12C <= 2 And DIFFERENCE12C >= -2 Then
cct1 = Right(Cells(Row, 3 + columnoffset), 10).Value
cct2 = Right(Cells(Row, 3 + columnoffset), 10).Value
rct1 = Right(Cells(Row, 4 + columnoffset), 10).Value
rct2 = Right(Cells(Row + 1, 4 + columnoffset), 10).Value
ez1 = Cells(Row + 1, 11)
If cct1 = cct2 And rct1 = rct2 Then
If ez1 > 0.5 Then
Cells(Row, 6).Value = "ez1"
End If
Rows(Row + 1).Delete
Deleted = True
Else
End If
End If
If Deleted = False Then Row = Row + 1
If Deleted = True Then LastRow = LastRow - 1
Loop Until Row > LastRow
</code>
I've read that I may need to use a SET statement but not sure what I need to do so any help would be welcome.
Thx
Jon