I have this function in VBA, everything works except when it reaches the For loop it just crashes and I have to close Excel and everything, not really sure how to fix it.
Private Sub checkDuplicates(x As Worksheet)
Dim n As Integer, i As Long, j As Long
Sort x
addheader x, "checkDup."
n = searchHeader(x, "checkDup.")
x.Columns(n) = 1
For i = 50 To 3 Step -1
For j = 1 To 5
If Not x.Cells(i, j) = x.Cells(i - 1, j).Value Then
x.Cells(i, n) = 0
Exit For
End If
Next j
Next i
End Sub
i = lastRow(x)are you calling a function here?