It sounds to me like a "database function" - dget, dsum, etc. I suggest you have a look in excel help at these functions as they can be pretty useful for stuff like that.
You would probably still need to run a little macro / sort to actually change positions in the table though.