I have the following code to compare two worksheets and if any of the account data is missing insert a row to add the missing data. When I ran the Macro it worked as expected accept it did the insert piece for every number after the first in the list that was not present on the compared master list. Any suggestions on how to ensure that only the missing account data is inserted as opposed to all subsequent rows in the comparative sheet?
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 Sht2.Range("A" & Cnt).Value <> Sht1.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"
Any guidance/assistance would be appreciated, and please excuse any posting etiquette miss-steps as this is my first post.
Thanks in advance.
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 Sht2.Range("A" & Cnt).Value <> Sht1.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"
Any guidance/assistance would be appreciated, and please excuse any posting etiquette miss-steps as this is my first post.
Thanks in advance.