I need to verify few formulas in my target workbooks. Each formula is a sum of few columns.
I want to search and highlight the cell in the column of the total when its value is different than the sum of its components (other cells on the same row).
Things are simple more or less when the sum is made only from few cells.
I was able to make a code work for me from scratches (I attached a sample EXCEL file):
Sub Verify_formulas()
For Each cl In Worksheets("CARS").Range("B4:B" & Worksheets("CARS").Cells(Rows.Count, 2).End(xlUp).Row)
If cl <> "" Then
If Application.Sum(cl.Offset(, 1), cl.Offset(, 2), cl.Offset(, 3), cl.Offset(, 4), cl.Offset(, 5)) <> cl Then cl.Interior.ColorIndex = 3
End If
Next cl
End Sub
However I have situations of 20 cells to add. They are near each other (consecutive/adjacent) on the same row...
... should be a way to write the code in a shorter format, but I don't know how without writing 20 times the "cl.Offset" string.
Please help!
Bookmarks