Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 20
Default Sorting data with a formula

Probably an obvious answer, but I can't seem to figure it out. I have 2
columns of data, like this:

Apples 7
Oranges 5
Pears 12
Bananas 2

I want to produce a 3rd column that sorts column A based on the value of
Column B, thus the 3rd column would be:

Bananas
Oranges
Apples
Pears

I know how to do that using "Data-Sort", but I want it to be done by
formula so I don't have to manually do the sorting.

Thanks,

Pete
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 913
Default Sorting data with a formula

On Mon, 21 Sep 2009 13:58:01 -0700, PeteJ
wrote:

Probably an obvious answer, but I can't seem to figure it out. I have 2
columns of data, like this:

Apples 7
Oranges 5
Pears 12
Bananas 2

I want to produce a 3rd column that sorts column A based on the value of
Column B, thus the 3rd column would be:

Bananas
Oranges
Apples
Pears

I know how to do that using "Data-Sort", but I want it to be done by
formula so I don't have to manually do the sorting.

Thanks,

Pete


If the data in column B are all unique, try the following formula in
cell C1:

=INDEX(A$1:A$4,MATCH(SMALL(B$1:B$4,ROW()),B$1:B$4, 0))

Note: This is an array formula that has to be confirmed with
CTRL+SHIFT+ENTER rather than just ENTER.

Copy down as far as there are data in columns A and B.

If the data in column B are not all unique, but there are no more than
1000 rows of data, all 1 or greater, try the following formula in cell
C1:

=INDEX(A$1:A$4,MATCH(SMALL(ROW()+1000*(B$1:B$4),RO W()),1000*(B$1:B$4)+ROW(),0))

Note: This is an array formula that has to be confirmed with
CTRL+SHIFT+ENTER rather than just ENTER.

Copy down as far as there are data in columns A and B.

Hope this helps / Lars-Åke


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 20
Default Sorting data with a formula


Thank you Lars-Ake,

I tried both these formulas, and the both work exactly the same, slightly
wrong. Does the data have to start in Row 1? My data is actually starting in
Row 3, and both formulas are producing results that miss the first 2 data
items. Does starting in Row 3 offset the "ROW()" function?

Pete


"Lars-Ã…ke Aspelin" wrote:

On Mon, 21 Sep 2009 13:58:01 -0700, PeteJ
wrote:

Probably an obvious answer, but I can't seem to figure it out. I have 2
columns of data, like this:

Apples 7
Oranges 5
Pears 12
Bananas 2

I want to produce a 3rd column that sorts column A based on the value of
Column B, thus the 3rd column would be:

Bananas
Oranges
Apples
Pears

I know how to do that using "Data-Sort", but I want it to be done by
formula so I don't have to manually do the sorting.

Thanks,

Pete


If the data in column B are all unique, try the following formula in
cell C1:

=INDEX(A$1:A$4,MATCH(SMALL(B$1:B$4,ROW()),B$1:B$4, 0))

Note: This is an array formula that has to be confirmed with
CTRL+SHIFT+ENTER rather than just ENTER.

Copy down as far as there are data in columns A and B.

If the data in column B are not all unique, but there are no more than
1000 rows of data, all 1 or greater, try the following formula in cell
C1:

=INDEX(A$1:A$4,MATCH(SMALL(ROW()+1000*(B$1:B$4),RO W()),1000*(B$1:B$4)+ROW(),0))

Note: This is an array formula that has to be confirmed with
CTRL+SHIFT+ENTER rather than just ENTER.

Copy down as far as there are data in columns A and B.

Hope this helps / Lars-Ã…ke



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 913
Default Sorting data with a formula

Replace ROW() with ROW()-2 if your data starts in row 3.

Lars-Åke

On Mon, 21 Sep 2009 18:04:01 -0700, PeteJ
wrote:


Thank you Lars-Ake,

I tried both these formulas, and the both work exactly the same, slightly
wrong. Does the data have to start in Row 1? My data is actually starting in
Row 3, and both formulas are producing results that miss the first 2 data
items. Does starting in Row 3 offset the "ROW()" function?

Pete


"Lars-Åke Aspelin" wrote:

On Mon, 21 Sep 2009 13:58:01 -0700, PeteJ
wrote:

Probably an obvious answer, but I can't seem to figure it out. I have 2
columns of data, like this:

Apples 7
Oranges 5
Pears 12
Bananas 2

I want to produce a 3rd column that sorts column A based on the value of
Column B, thus the 3rd column would be:

Bananas
Oranges
Apples
Pears

I know how to do that using "Data-Sort", but I want it to be done by
formula so I don't have to manually do the sorting.

Thanks,

Pete


If the data in column B are all unique, try the following formula in
cell C1:

=INDEX(A$1:A$4,MATCH(SMALL(B$1:B$4,ROW()),B$1:B$4, 0))

Note: This is an array formula that has to be confirmed with
CTRL+SHIFT+ENTER rather than just ENTER.

Copy down as far as there are data in columns A and B.

If the data in column B are not all unique, but there are no more than
1000 rows of data, all 1 or greater, try the following formula in cell
C1:

=INDEX(A$1:A$4,MATCH(SMALL(ROW()+1000*(B$1:B$4),RO W()),1000*(B$1:B$4)+ROW(),0))

Note: This is an array formula that has to be confirmed with
CTRL+SHIFT+ENTER rather than just ENTER.

Copy down as far as there are data in columns A and B.

Hope this helps / Lars-Åke




  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 806
Default Sorting data with a formula

Hello Pete,

I suggest to use this example:
http://sulprobil.com/html/sorting.html

Regards,
Bernd


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data sorting formula nir020 Excel Worksheet Functions 2 May 5th 09 10:14 AM
Sorting data derived from formula newbie Excel Worksheet Functions 6 June 6th 08 09:03 PM
Formula won't adjust after sorting data mmcap Excel Worksheet Functions 11 January 22nd 07 06:53 PM
sorting data, formula contance jeff New Users to Excel 2 April 4th 06 04:46 AM
Sorting Data and Formula help... Jambruins Excel Discussion (Misc queries) 3 March 2nd 05 02:29 PM


All times are GMT +1. The time now is 05:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"