Sorting a Table with relative references

User avatar
StuartR
Administrator
Posts: 12604
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Sorting a Table with relative references

Post by StuartR »

I have a table with two columns. The table is in columns A and B of a worksheet called "Categories"
The first column, "Category" is fixed text.
The second column"Date used" is calculated from category. The formula in cell B2 looks like this... =MAXIFS(Transactions!$C$10:C$25000,Transactions!$B$10:B$25000,Categories!$A2)

My problem is that I want to sort the table by Date used. When I do this the relative references (Categories!$A2) do not update to match the new row that the cell is in. So all the dates are in the wrong rows.
StuartR


User avatar
HansV
Administrator
Posts: 78478
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Sorting a Table with relative references

Post by HansV »

I assume that you either selected a cell in the Date Used column or the entire table before you sorted.
If you do it that way, the categories and dates will be moved together, and the formula in B2 should still refer to $A2.

If you just sort the date column, the dates won't match the categories anymore.

S0446.png
SortTable.xlsx
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

User avatar
StuartR
Administrator
Posts: 12604
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Sorting a Table with relative references

Post by StuartR »

I tried selecting the whole table, as well as selecting a single cell in the table, but it didn't help...
Sort problem 1.png
Sort problem 2.png
Sort problem 3.png
You do not have the required permissions to view the files attached to this post.
StuartR


User avatar
HansV
Administrator
Posts: 78478
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Sorting a Table with relative references

Post by HansV »

Ah - try removing "Categories!" from "Categories!$A2"

=MAXIFS(Transactions!$C$10:C$25000,Transactions!$B$10:B$25000,$A2)
Best wishes,
Hans

User avatar
StuartR
Administrator
Posts: 12604
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Sorting a Table with relative references

Post by StuartR »

Brilliant, that fixed it, thank you!
StuartR