Forum Discussion
relative cell references in a formula
Thanks.
- DavidHeathDec 27, 2021Copper Contributor
PeterBartholomew1 sorry, that didn't work. I created the table (those alternating stripes are annoying... but, no matter), but when I sorted on a column with the automatically applied filter tool, the cell retained the formula reference for the location it had before the sort, rather than the cell five to the right of its current position.
- PeterBartholomew1Dec 27, 2021Silver Contributor
It appears that we have very different work practices, but my best guess as to the formula you require might be as shown in the image
I have applied your Sheet names to the Tables and used them in preference to references to the Tabs. As you might observe, I always format Tables to 'White, Table Style Light 1' and deselect Banded Rows. I would normally deselect Filter Buttons too but that is not what you require. The criterion value is looked up by column name and the particular value is part of the current record. The criterion Range is the entire column of the Master Table.
This should be robust to any sorting or the insertion of rows or columns, but If it is not what you require then either I or NowshadAhmed may provide further assistance.
 - NowshadAhmedDec 27, 2021Iron ContributorYou can go to the Table Tools tab and deactivate the coloured bands/stripes (yes, it is annoying at times).
After applying the formatted table, re-enter the formula in the first cell of the stock column (you might want to clear the old formula from the enyire column first). Excell will update all the rows with the new formula. Now sorting won't be the problem because you are referring to a data in the same row.
Another note: while creating the formatted table, select the entire data manually including the headers. When given an option, select 'my table has headers' option and continue.
Alternately: To solve the reference, you can make use of INDIRECT function. From what I understand, you don't need it but if nothing works, this might help.