Sorting moves my references

sriche01

Board Regular
Joined
Dec 24, 2013
Messages
136
Office Version
  1. 365
Platform
  1. Windows
I have an inventory workbook with many sheets that are interconnected for my greenhouse operation. On the sheet with actual inventory on it, each line represents a group of plants. Columns indicate such things as the item number, location, quantity, last transplant date etc. A few columns have formulas that refer to the item number in that same line, then look up the expected shipping percentage for that item stored on another sheet.

Example: This sheet is named "Inv"
Item NumberShipping %Formula for b column
BUDD BLK1890%=sumif('Item Overview'!$G$4:$G$831,inv!$a1,'Item Overview'!$Q$4:$Q$831
BUXU GNG1892%=sumif('Item Overview'!$G$4:$G$831,inv!$a2,'Item Overview'!$Q$4:$Q$831
CHAM GOM1085%=sumif('Item Overview'!$G$4:$G$831,inv!$a3,'Item Overview'!$Q$4:$Q$831

<tbody>
</tbody>












In the example, Item Overview is a static list with the item number as primary key (no duplicates) with information about each item (column g) including shipping % (column q).

The problem is that my inventory sheet (the above table) is sorted frequently, sometimes by location, sometimes by item number, and occasionally by other columns. Every time that it is sorted, the reference in the above formula to the item number on the same row moves to reference a different row. So, in the above example, I would get the wrong shipping % to show up for each item because it is no longer referring to the item number in the same row as the formula.

So far, any time I sort, I correct the reference in the top line and copy down the 1500 or so rows, but I was wondering if there is a trick to get the reference to move correctly with the sort. Thanks!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
you could run a macro that puts the correct formulas in the top row and copies them down - just click it whether a sort has occurred or not
 
Upvote 0
Remove the inv references:

=sumif('Item Overview'!$G$4:$G$831,$a1,'Item Overview'!$Q$4:$Q$831

rather than:
=sumif('Item Overview'!$G$4:$G$831,inv!$a1,'Item Overview'!$Q$4:$Q$831

and the sorting will be fine.
 
Upvote 0
Thank you both. Rory, your fix is both simple and effective. Many thanks!
 
Upvote 0
I hope it's ok to jump on this thread.

This was a great little fix. I was wondering if anyone knows why Excel adds the local worksheet to some formulas even if we are referencing the same tab? I usually write the formula pointing to "A3" but later when I return, the formula becomes Tab!A3
 
Upvote 0
If you click another sheet (eg to refer to a range on it) and then click back to the formula sheet, any cells you select on the formula sheet are automatically prefixed with the sheet name. It's annoying!
 
Upvote 0

Forum statistics

Threads
1,214,817
Messages
6,121,717
Members
449,050
Latest member
MiguekHeka

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top