Share via

VBA Runtime Error 1004 “Application-defined or Object-defined error” when checking for duplicates in two colums

Anonymous
2018-10-11T10:29:18+00:00

I am having an issue with a Error 1004 "Application-defined or Object-defined error".

I have used the exact same code many times before but for some reason I cannot make it function in this sub .

Sub Checkduplicates()

Dim tracker As Workbook

Set tracker = ActiveWorkbook

With tracker.Sheets("Tracker")

Dim sEntity As String, sAmt As Double, sRow As Integer

sEntity = .Cells(row, 6).Value sAmt = .Cells(row, 11).Value

If row > 1010 Then sRow = row - 1000 Else sRow = 4

For sRow = sRow To row - 1 If .Cells(sRow, 6).Value = sEntity And .Cells(sRow, 11).Value = sAmt Then

  Call GetAnswer

End If

Next sRow

End With

End Sub

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. OssieMac 48,001 Reputation points Volunteer Moderator
    2018-10-11T10:52:18+00:00

    Two problems.

    Main problem is that no value has been assigned to Row and therefore Row equals zero and there is no row zero and the code should fail with the error you have indicated on the following line of code.

    sEntity = .Cells(Row, 6).Value

    Also Row is a reserved word and it is not good programming to use it as a variable. Preferable to use lRow or lngRow.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2018-10-11T10:50:02+00:00

    row isn't defined so the error occurs when you are trying to assign sEntity

    Was this answer helpful?

    0 comments No comments