Sorting doesn't sort

theDrew

Board Regular
Joined
May 6, 2003
Messages
104
Hi all,

I have a sheet that lists revenues by country, as such:
M7 GMD EMIS Reports.xls
ABCD
1CountryRevenue
2ABUDHABI$0
3ARGENTINA$190,825
4AUSTRALIA$436,781
5BAHAMAS$0
6BAHRAIN$862
7BANGLADESH$4,487
8BARBADOS$0
9BOSNIA-HERZEGOVINA$0
10BRAZIL$1,696,189
Country-Region (2)


The data in the "Revenue" column is calculated via the following formula:
Code:
=SUMIF('Sold Cases'!$D:$D,'Country-Region (2)'!$A2,'Sold Cases'!$N:$N)

I want to sort the data in descending order by Revenue. I run the Sort function and select Sort by Revenue - Descending. This sorts the Country column, but does not sort the Revenue column, as follows:
M7 GMD EMIS Reports.xls
ABCD
1CountryRevenue
2BRAZIL$0
3AUSTRALIA$190,825
4ARGENTINA$436,781
5BANGLADESH$0
6BAHRAIN$862
7ABUDHABI$1,696,189
8BAHAMAS$4,487
9BARBADOS$0
10BOSNIA-HERZEGOVINA$0
Country-Region (2)


If I eliminate the formula by copying the Revenue column and then pasting the results via Paste Special - Values Only, then the data sorts correctly. I don't want to have to do this, though.

What could be the cause of this? It is driving me crazy!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
theDrew

What do you actually have selected when you try the sort?

I would recommend you select both columns and rather than just hitting the sort button on the toolbar goto Data>Sort...

If that doesn't work then there's probably something else going on.:)
 
Upvote 0
theDrew

What do you actually have selected when you try the sort?

I would recommend you select both columns and rather than just hitting the sort button on the toolbar goto Data>Sort...

If that doesn't work then there's probably something else going on.:)

That's what I've been doing (I haven't been using the toolbar).
 
Last edited:
Upvote 0
Hey...

sorry for the misinformation. I was pulling from memory (not always the smart thing to do in my case!:))

So I did a little testing. I thought it might have been that you referenced a full column, but that seemed to work just fine (in xl2007 at least).

I'm curious... if you have an autofilter on the data, will it sort?
 
Upvote 0
Hey...

sorry for the misinformation. I was pulling from memory (not always the smart thing to do in my case!:))

So I did a little testing. I thought it might have been that you referenced a full column, but that seemed to work just fine (in xl2007 at least).

I'm curious... if you have an autofilter on the data, will it sort?


No, it doesn't work right if I use an autofilter either. This is a spreadsheet that is generated by an application (think "Click here to download in MSExcel format"), so I suspect that something screwy happens during the automated creation of the sheet.
 
Upvote 0
Hi,

The problem is in referencing to the current sheet cell in a formula.

Instead of:
Code:
=SUMIF('Sold Cases'!$D:$D,'Country-Region (2)'!$A2,'Sold Cases'!$N:$N)

use this one:
Code:
=SUMIF('Sold Cases'!$D:$D,$A2,'Sold Cases'!$N:$N)

Then sort & enjoy :)

Vladimir
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,071
Messages
6,122,964
Members
449,094
Latest member
Anshu121

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