I have the below macro that compares two lists to each other. You paste the New and Old lists into columns B and H and it tests for any accounts added to the new list and also for accounts that were dropped from the old list. I need to add a test that if it finds no changes to not perform the part where it adds the countif formula and skips to the second part of the macro to test for the dropped. And again if it finds no changes skip the portion of the code that adds forumals. I hope this makes sense. Please let me know if I need to clarify anything!
Code:
Sub CompareColumnB2H()
Application.Calculation = xlCalculationManual
Dim LstRwB&, LstRwH&, LstRwM, LstRwP, bVal As Range
LstRwB = Cells(Rows.Count, "B").End(xlUp).Row
LstRwH = Cells(Rows.Count, "H").End(xlUp).Row
For Each bVal In Range("B3:B" & LstRwB)
If Application.WorksheetFunction.CountIf(Range("H3:H" & LstRwH), bVal) = 0 Then _
Cells(Rows.Count, "M").End(xlUp)(2).Value = bVal
Next
For Each bVal In Range("H3:H" & LstRwH)
If Application.WorksheetFunction.CountIf(Range("B3:B" & LstRwB), bVal) = 0 Then _
Cells(Rows.Count, "P").End(xlUp)(2).Value = bVal
Next
LstRwM = Cells(Rows.Count, "M").End(xlUp).Row
LstRwP = Cells(Rows.Count, "P").End(xlUp).Row
Range("N3").Value = "=vlookup(m3,b$3:c$50000,2,false)"
Range("N3").AutoFill Destination:=Range("N3:N" & LstRwM)
Range("Q3").Value = "=vlookup(p3,h$3:i$50000,2,false)"
Range("Q3").AutoFill Destination:=Range("Q3:Q" & LstRwP)
Application.Calculation = xlCalculationAutomatic
Range("M3:Q50000").Value = Range("M3:Q50000").Value
Sheets.Add After:=Sheets("Paste Here")
ActiveSheet.Name = "Output"
Sheets("Paste Here").Columns("M:Q").Copy
Sheets("Output").Paste
Sheets("Output").Move
End Sub