I have a VBA code that looks at spreadsheet 1 and compares to spreadsheet 2. If it finds a match it then grabs the check# from the next cell down. How do I get it to look at the cell directly below the check# to see if the check was voided and then grab the next check below that? I have attached the code I already have.
VBA Code:
' Assuming worksheet 1 is the first worksheet and worksheet 2 is the second worksheet. Comparing data between sheets.
Set ws1 = ThisWorkbook.Worksheets(1)
Set ws2 = ThisWorkbook.Worksheets(2)
lastRow1 = ws1.Cells(ws1.Rows.Count, "A").End(xlUp).Row
lastRow2 = ws2.Cells(ws2.Rows.Count, "A").End(xlUp).Row
For i = 2 To lastRow1 ' Assuming data starts from row 2
For j = 2 To lastRow2 ' Assuming data starts from row 2
If ws1.Cells(i, "A").Value = ws2.Cells(j, "A").Value And _
ws1.Cells(i, "F").Value = ws2.Cells(j, "C").Value Then
ws1.Cells(i, "J").Value = ws2.Cells(j + 1, "E").Value ' Value from worksheet 2 column E, down one cell
Exit For ' No need to continue checking if a match is found
End If
Next j
Next i
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic