Actually, if columns Q:R are available to use as helper columns, though the code is a bit longer, the formulas could be simplified with this code.
<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> CheckTotals()<br> <SPAN style="color:#00007F">Dim</SPAN> lr1 <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, lr2 <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br> <SPAN style="color:#00007F">Dim</SPAN> frmlaP <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, frmlaQ <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, frmlaR <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br> <br> <SPAN style="color:#00007F">Const</SPAN> frmlabaseP <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN> = "=IF(I2=I3,"""",IF(SUMIF(I$2:I2,I2,F$2:F2)" _<br> & "=INDEX(Sheet2!K$2:O$#,Q2,R2),""OK"",""ERROR""))"<br> <SPAN style="color:#00007F">Const</SPAN> frmlabaseQ <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN> = "=MATCH(I2,Sheet2!Q$2:Q$#,0)"<br> <SPAN style="color:#00007F">Const</SPAN> frmlabaseR <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN> = "=MATCH(E2,INDEX(Sheet2!I$2:M$#,Q2,0))"<br> <br> <SPAN style="color:#00007F">With</SPAN> Sheets("Sheet2")<br> lr2 = .Range("Q" & .Rows.Count).End(xlUp).Row<br> End <SPAN style="color:#00007F">With</SPAN><br> frmlaP = Replace(frmlabaseP, "#", lr2, 1, -1, 1)<br> frmlaQ = Replace(frmlabaseQ, "#", lr2, 1, -1, 1)<br> frmlaR = Replace(frmlabaseR, "#", lr2, 1, -1, 1)<br> <SPAN style="color:#00007F">With</SPAN> Sheets("Sheet1")<br> lr1 = .Range("I" & .Rows.Count).<SPAN style="color:#00007F">End</SPAN>(xlUp).Row<br> Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br> Range("P1").Value = "Check Totals"<br> <SPAN style="color:#00007F">With</SPAN> .Range("P2:P" & lr1)<br> .Offset(, 1).Formula = frmlaQ<br> .Offset(, 2).Formula = frmlaR<br> .Formula = frmlaP<br> .Value = .Value<br> .Offset(, 1).Resize(, 2).ClearContents<br> <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br> Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN><br> <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>End <SPAN style="color:#00007F">Sub</SPAN><br></FONT>