I have two tables in two different sheets: one table contains the source data that I input by hand (in the sheet "Roadmap Data"), the other table (in the sheet "Overview") would be another container to keep the data that could change in the Roadmap Data sheet. My aim is copy the rows of the table in the Roadmap Data sheet only if not already present in the table of the Overview sheet. Here below the code I wrote, I took inspiration from another post
Public Sub CopyRowsAcross()
Dim ione, itwo As Integer
Dim ws1 As Worksheet: Set ws1 = ThisWorkbook.Sheets("Roadmap Data")
Dim ws2 As Worksheet: Set ws2 = ThisWorkbook.Sheets("Overview")
For ione = 3 To ws1.Range("B65536").End(xlUp).Row
itwo = 3
Do Until itwo = ws2.Range("B65536").End(xlUp).Row + 1
If ws1.Cells(ione, 2) = ws2.Cells(itwo, 2) And ws1.Cells(ione, 3) = ws2.Cells(itwo, 3) And ws1.Cells(ione, 4) = ws2.Cells(itwo, 4) And ws1.Cells(ione, 5) = ws2.Cells(itwo, 5) And ws1.Cells(ione, 6) = ws2.Cells(itwo, 6) And ws1.Cells(ione, 7) = ws2.Cells(itwo, 7) And ws1.Cells(ione, 8) = ws2.Cells(itwo, 8) Then
Exit Do
Else
ws1.Rows(ione).Copy ws2.Rows(ws2.Cells(ws2.Rows.Count, 2).End(xlUp).Row + 1)
Exit Do
End If
itwo = itwo + 1
Loop
Next ione
End Sub
The source data is something like this: enter image description here
but the result of the macro is wrong: enter image description here
Probably there's something wrong in the way I wrote the do until loop, I think I need a for cycle that loops the rows of the Overview sheet with "Or" conditions, but I can't image how to do it. Any suggestions to simplify the condition I used to verify if the rows of two tables are the same is appreciated.