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!
 
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

Ding ding ding ding we have ourselves a winner. Thanks ZVI!
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Dear Vladimir,

I just logged in to thank you for this solution. Works great!

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
 
Upvote 0
Welcome aboard Refugee and thank you for the response! :)
 
Upvote 0
Dear Vladimir,

I just logged in to thank you for this solution. Works great!


Unfortunately, I have ran into a problem nonetheless :confused:. All the references to the original sheet are gone, but still the data keeps getting messed up. The issue is the following:
I have a (quite elaborate) sheet, with many links to different tabs. However, there are a few fields which are empty and should be filled out.

Imagine:
Brand - Product - Price - Comment

Here the last 2 columns would be empty until filled out. I know that Excel has issues with empty values and sorting. It might be smarter to avoid it, but there is really not a whole lot of different options available as I need others to add comments and prices, but only in some fields.
Strangely enough, another tab which also has empty values which need 'comment' fields are perfectly sorting in any way possible. What is different between this tab and the other than?

Any thoughts would be greatly appreciated! ;)
 
Upvote 0
Unfortunately, I have ran into a problem nonetheless :confused:. All the references to the original sheet are gone, but still the data keeps getting messed up. The issue is the following:
I have a (quite elaborate) sheet, with many links to different tabs. However, there are a few fields which are empty and should be filled out.

Imagine:
Brand - Product - Price - Comment

Here the last 2 columns would be empty until filled out. I know that Excel has issues with empty values and sorting. It might be smarter to avoid it, but there is really not a whole lot of different options available as I need others to add comments and prices, but only in some fields.
Strangely enough, another tab which also has empty values which need 'comment' fields are perfectly sorting in any way possible. What is different between this tab and the other than?

Any thoughts would be greatly appreciated! ;)

PROBLEM SOLVED!
Apparently, some of the VLOOKUP functions were messing things up. Because the first item ('value') referred to entire columns, instead of specific cells. Once this was corrected AND I corrected for the references to the original sheet that include the name of the sheet (i.e. index!a:b,2,0 >> a:b,2,0) all was fine. Fine being: I can sort even empty values!

For me this is essential as I need to add 'comment fields' to existing data pulled from various sources. This means there will always be empty cells, which I don't want to fill with values every time.

Hope this helps for others as well. Have a great day!
 
Upvote 0

Forum statistics

Threads
1,215,674
Messages
6,126,149
Members
449,294
Latest member
Jitesh_Sharma

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