I am attempting to compare lists of data and insert missing rows. The below code is intended to do so, however, if it encounters an items in the Account Master List that is not on the Execute billing list it will insert rows for everything that comes after that row of data. Any help is appreciated.
Code:
Dim Cnt As Long
Dim Sht1 As Worksheet
Dim Sht2 As Worksheet
Set Sht1 = Sheets("Execute Billing")
Set Sht2 = Sheets("Account Master File")
For Cnt = 2 To Sht1.Range("A" & Rows.Count).End(xlUp).Row
If Sht1.Range("A" & Cnt).Value <> Sht2.Range("A" & Cnt) Then
Sht2.Rows(Cnt).Insert
Sht2.Range("A" & Cnt).Value = Sht1.Range("A" & Cnt).Value
Selection.NumberFormat = "000000000000000"
Sht2.Range("B" & Cnt).Value = Sht1.Range("C" & Cnt).Value
Sht2.Range("C" & Cnt).Value = "NEW"
Sht2.Range("D" & Cnt).FormulaR1C1 = "=SUM(RC[-1]*5+18)"
Sht2.Range("E" & Cnt).FormulaR1C1 = "=RC[4]&TEXT(RC[-4],""000000000000000"")&RC[5]"
Sht2.Range("F" & Cnt).FormulaR1C1 = "=SUM(RC[-2]*100)"
Sht2.Range("H" & Cnt).FormulaR1C1 = "=RC[-3]&TEXT(RC[-2],""0000000000000"")"
Sht2.Range("I" & Cnt).Value = "'001"
Sht2.Range("J" & Cnt).Value = "'0125"
End If
Next Cnt