For example, take the formula in cell G3, I want to summarize 246 lines, the last line is in cell B253 and the first line is 245 over cell B253, in this case the first cell is a cell B8.
It's may be my fault to make myself clear to you, What I want to ask is why you selected B253 as last line in your G3 formula? Why you started that as your starting point?
I think the oddness in your formulas arises because you count all the way to the end, and then backwards again. Wouldn't it be better just to count forwards?
I attach an alternative that does just that. Note that I created some named formulas, including one for the total number of records in your dataset: I didn't use this in the end, but you could use it if for some reason you need to keep the "forwards-backwards" approach.