the OnError Resume Next line is your problem.
I've made your code a little easier to read and made a minor adjustment. Can you test it for me to see if it still behaves in the same way. If an error pops up, tell me what the error says and what line it occurs on.
Dim j As Integer
Dim book1 As Workbook
Dim book2 As Workbook
Dim sht1 As Worksheet, sht2 As Worksheet, x, y
Set book1 = Workbooks("Proves Dades Operatives")
Set book2 = Workbooks("R71 1i2")
Set sht1 = book1.Sheets("Hoja1")
Set sht2 = book2.Sheets("Hoja3")
i = 2
Do While Cells(i, 1).Value <> ""
x = Application.VLookup(sht1.Cells(i, 1), sht2.Range("A:H"), 7, 0)
y = Application.VLookup(sht1.Cells(i, 1), sht2.Range("A:H"), 8, 0)
If x = 2 And y = 1 Then
Cells(i, 5) = "T+1"
ElseIf x = 0 And y = 0 Then
Cells(i, 5) = "T+0"
ElseIf x = 1 And y = 1 Then
Cells(i, 5) = "T-1"
ElseIf x = 1 And y = 2 Then
Cells(i, 5) = "T-2"
ElseIf x = 1 And y = 3 Then
Cells(i, 5) = "T-3"
End If
i = i + 1
' On Error Resume Next
Loop
You can also test the following.
Dim i As Integer
Dim j As Integer
Dim book1 As Workbook
Dim book2 As Workbook
Dim sht1 As Worksheet, sht2 As Worksheet, x, y
Set book1 = Workbooks("Proves Dades Operatives")
Set book2 = Workbooks("R71 1i2")
Set sht1 = book1.Sheets("Hoja1")
Set sht2 = book2.Sheets("Hoja3")
i = 2
Do While Cells(i, 1).Value <> ""
x = Application.VLookup(sht1.Cells(i, 1), sht2.Range("A:H"), 7, 0)
y = Application.VLookup(sht1.Cells(i, 1), sht2.Range("A:H"), 8, 0)
Select Case True
Case x = 2 And y = 1: Cells(i, 5) = "T+1"
Case x = 0 And y = 0: Cells(i, 5) = "T+0"
Case x = 1 And y = 1: Cells(i, 5) = "T-1"
Case x = 1 And y = 2: Cells(i, 5) = "T-2"
Case x = 1 And y = 3: Cells(i, 5) = "T-3"
End Select
i = i + 1
Loop
This code should NOT require the On Error Resume Next line at all.