我遇到错误1004“应用程序定义的错误或对象定义的错误”的问题。
我之前使用过完全相同的代码很多次,但是由于某种原因我无法使其在此子代码中起作用。
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
答案 0 :(得分:0)
row
和sEntity = .Cells(row, 6).Value
中的 sAmt = .Cells(row, 11).Value
未声明和未定义。看来它应该是F列中最后一个填充的单元格。
Sub Checkduplicates()
Dim tracker As Workbook
Set tracker = ActiveWorkbook
With tracker.Sheets("Tracker")
Dim sEntity As String, sAmt As Double, sRow As LONG, rw as LONG
rw = .cells(.rows.count, "F").end(xlup).row
sEntity = .Cells(rw, 6).Value
sAmt = .Cells(rw, 11).Value
If Row > 1010 Then sRow = Row - 1000 Else sRow = 4
For sRow = sRow To rw - 1
If .Cells(sRow, 6).Value = sEntity And .Cells(sRow, 11).Value = sAmt Then
Call GetAnswer
End If
Next sRow
End With
End Sub
明确使用选项。