Forum Discussion
maintaining a cell reference despite changing the cell location through sorting
The workaround with the reference could be organize as
(assuming your data is in column A starting from cell A1 and you reference on the value of the cell in 15th position, other words on A15 in unfiltered range)
=INDEX($A:$A, COUNTA($A$1:INDEX($A:$A,ROW(A15)-ROW($A$1)+1)) - SUBTOTAL(103,$A$1:INDEX($A:$A,ROW(A15)-ROW($A$1)+1)) + ROW(A15)-ROW($A$1)+1 )
Not very practical...
- BerlinerTourGuideAug 11, 2019Copper Contributor
SergeiBaklan and 'the world': well, I have a work-around, at least for the special, but very frequent case of sums: if you had marked a certain minor block of numbers as a sum, and then change the order completely via sorting, the sum would be wrong afterwards... to avoid this one must open an auxiliary column (which can be removed afterwords from view); in this column one references the first number of the block, then drags down to the end of the block; so you reference all intended numbers of the block; then in the (visible) column that 'counts' you write a sum that includes all lines of your sheet (as many lines as there are, from the first to the last... so you may have: sum(a1:a1000) but only three numbers in that column...); now you can change the order of the lines as you whish, and the sum remains correct... well, almost... excel may change the range of the sum... (annoying...); so either adjust the range which is quickly done, or place the sum in the first line or another line whose position is not changed...😉
- BerlinerTourGuideJul 25, 2019Copper Contributor
SergeiBaklan : thanks, but indeed: not very practical...
I have lots of rows which belong to different categories (marked out in various columns). now I'd like - in a simple way) to sort (not filter, like PReagan said) the rows according to the categories, then form sums of the grouped row-categories, reference them, and then change the order of the rows again... so what would be needed is an automatic transformation of e.g. a1:a3 into a1+a2+a3 and then links that move automatically with each of the re-sorted cells...
note: this is the first time that I could not solve a task with excel... ;-)