Hi everyone,

Thanks in advance for those who'll help me. I'll go staight to my problem: I have a list of ISIN and i'm writing a code to update all the date of those ISINs in the following columns. This data is found in another workbook (called book2 in the code). My problem is that when the ISIN is not found in "book2" the code returns the value "T+1" instead of leaving the data that was already there. What i would like the code to do is when the ISIN in book1 is not found in book2 then leave the data that was already there in book1. Find attached below the code I'm having problems with. If someone needs further explanation let me know please. Thanks in advance guys!


Dim i As Integer
Dim j As Integer
Dim book1 As Workbook
Dim book2 As Workbook


Set book1 = Workbooks("Proves Dades Operatives")
Set book2 = Workbooks("R71 1i2")


i = 2


Do While Cells(i, 1).Value <> ""


 If Application.WorksheetFunction.VLookup(book1.Sheets("Hoja1").Cells(i, 1), book2.Sheets("Hoja3").Range("A:H"), 7, 0) = 2 And Application.WorksheetFunction.VLookup(book1.Sheets("Hoja1").Cells(i, 1), book2.Sheets("Hoja3").Range("A:H"), 8, 0) = 1 Then
  Cells(i, 5) = "T+1"
 ElseIf Application.WorksheetFunction.VLookup(book1.Sheets("Hoja1").Cells(i, 1), book2.Sheets("Hoja3").Range("A:H"), 7, 0) = 0 And Application.WorksheetFunction.VLookup(book1.Sheets("Hoja1").Cells(i, 1), book2.Sheets("Hoja3").Range("A:H"), 8, 0) = 0 Then
  Cells(i, 5) = "T+0"
 ElseIf Application.WorksheetFunction.VLookup(book1.Sheets("Hoja1").Cells(i, 1), book2.Sheets("Hoja3").Range("A:H"), 7, 0) = 1 And Application.WorksheetFunction.VLookup(book1.Sheets("Hoja1").Cells(i, 1), book2.Sheets("Hoja3").Range("A:H"), 8, 0) = 1 Then
  Cells(i, 5) = "T-1"
 ElseIf Application.WorksheetFunction.VLookup(book1.Sheets("Hoja1").Cells(i, 1), book2.Sheets("Hoja3").Range("A:H"), 7, 0) = 1 And Application.WorksheetFunction.VLookup(book1.Sheets("Hoja1").Cells(i, 1), book2.Sheets("Hoja3").Range("A:H"), 8, 0) = 2 Then
  Cells(i, 5) = "T-2"
 ElseIf Application.WorksheetFunction.VLookup(book1.Sheets("Hoja1").Cells(i, 1), book2.Sheets("Hoja3").Range("A:H"), 7, 0) = 1 And Application.WorksheetFunction.VLookup(book1.Sheets("Hoja1").Cells(i, 1), book2.Sheets("Hoja3").Range("A:H"), 8, 0) = 3 Then
  Cells(i, 5) = "T-3"
     
End If


    i = i + 1
 
 On Error Resume Next


Loop