I have a sheet that looks like:

Code:

```
A B C D E F G H I
1 ID UserID Firstname Surname Type Score1 Score2 Score3 Score4
2
3
.
.
.
.
## (could be anything)
```

There are two types of errors that can occur in the data that i need to find:

- If there is a duplicate UserID (column B) I need to put a 1 in Column M of all rows that are duplicate

- If any of the scores (columns F-I) are greater than 5 or less than 0 then its an error, also sometimes it will have #value in there. In both of these cases i need to put a 1 in column L and clear the particular score that is giving an error.

It works fine, but is really slow (obviously.. its pretty poorly written) for alot of rows. I don't mind doing a mixture of code/formula (i assume the duplicate one can be done by formula).

Code:

```
Sub check_errors()
Dim i
Sheets("Summary of Data").Activate
If Range("A3") = "" Then Exit Sub
If Range("A4") = "" Then Exit Sub
Application.ScreenUpdating = False
Range("M3:M10000").ClearContents
Rows("3:1000").Interior.ColorIndex = 0
For i = 3 To Range("A3").End(xlDown).Row
Call check_dup(i)
Call check_error(i)
Next i
Application.ScreenUpdating = True
Range("A3").Select
End Sub
Sub check_error(i)
Range("L" & i) = ""
If WorksheetFunction.IsError(Range("F" & i)) Then Range("F" & i) = "-1"
If WorksheetFunction.IsError(Range("G" & i)) Then Range("G" & i) = "-1"
If WorksheetFunction.IsError(Range("H" & i)) Then Range("H" & i) = "-1"
If WorksheetFunction.IsError(Range("I" & i)) Then Range("I" & i) = "-1"
If ((Range("F" & i).Value < 0) Or (Range("F" & i).Value > 5)) Then
Range("F" & i).Formula = ""
Range("L" & i) = 1
End If
If ((Range("G" & i).Value < 0) Or (Range("G" & i).Value > 5)) Then
Range("G" & i).Formula = ""
Range("L" & i) = 1
End If
If ((Range("H" & i).Value < 0) Or (Range("H" & i).Value > 5)) Then
Range("H" & i).Formula = ""
Range("L" & i) = 1
End If
If ((Range("I" & i).Value < 0) Or (Range("I" & i).Value > 5)) Then
Range("I" & i).Formula = ""
Range("L" & i) = 1
End If
End Sub
Sub check_dup(i)
Dim j
Dim checkID
checkID = Range("B" & i).Value
Range("B" & i).Select
For j = 3 To Range("A3").End(xlDown).Row
'Range("M" & j) = ""
'Range("M" & i) = ""
If j <> i Then
If checkID = Range("B" & j).Value Then
Range("M" & j) = 1
Range("M" & i) = 1
End If
End If
Next j
End Sub
```

Thanks for reading!