Excel - Sort using formula
Asked By StephenT
09-Feb-10 10:06 AM
Hi
I'd like to sort a column of data using a formula, but I am having
challenges because there is non-unique data
eg. Source data : Names in col A and scores in col B
A B
Name 1 21
Name 2 30
Name 3 21
Name 4 40
etc.
Output : I want to be able to re-order the names using the scores, so in Col
C I'd have the scores in ascending order, and the corresponding name in Col D
C D
21 Name 1
21 Name 3
30 Name 2
40 Name 4
I cannot use the sort options (as I am building for beginners who may not be
able to use it) and would prefer to not use a macro (for the same reason).
Have tried a few different ways but keep getting stumped by the multiple
names associated with a single score (limiting the potential for an
index/match)
Any ideas?
Microsoft Excel
(1)
Excel
(1)
SUMPRODUCT
(1)
INDEX
(1)
MATCH
(1)
Macro
(1)
ROWS
(1)
BiffMicrosoft
(1)
Russell Dawson replied to StephenT
I know what you have asked for but surely using a macro that only involves
the users input of Ctrl-A or whatever must be the simplest way of achieving
your goal.
--
Russell Dawson
Excel Student
StephenT replied to Russell Dawson
Yes young jedi, however the easiest to code is not always the best approach
I consider myself advanced in Excel but I cannot crack this nut
If one of the advanced users in this forum can solve this problem in-cell
then I will humbly bow and henceforth proclaim their infinite intelligence
s
מיכאל (מיקי) אבידן replied to StephenT
The formula in col. "D" is a Array Formula.
It should be entered with CTRL+SHIFT+ENTER rather than with simply ENTER.
The curly brackets {} are not to be typed manually, those are entered by the
???Excel???, when the formula is entered as an Array formula.
Be my guest to fine-tune the formula to your specific needs.
http://img692.imageshack.us/img692/7601/nonamez.png
Micky
Russell Dawson replied to StephenT
As Ernest Hemingway said, "My aim is to put down on paper what I see and what
I feel in the best and simplest way"
Regards
Russell Dawson
Excel Student
T. Valko replied to Russell Dawson
Try this...
Enter this formula in C2:
=SMALL(B$2:B$5,ROWS(C$2:C2))
Enter this array formula** in D2:
=INDEX(A$2:A$5,MATCH(SMALL(B$2:B$5+ROW(B$2:B$5)/10^10,ROWS(C$2:C2)),B$2:B$5+ROW(B$2:B$5)/10^10,0))
** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT
key then hit ENTER.
Select both C2 and D2 then drag copy down as needed.
--
Biff
Microsoft Excel MVP
Bernd P replied to StephenT
Hello,
I suggest to use this:
http://sulprobil.com/html/sorting.html
Regards,
Bernd
StephenT replied to Bernd P
That works a charm, great use of SumProduct thanks Bernd! I bend knee in
humility.
A summary might help: Drag the following formula from C1 through to C4. Keep
in mind that this is an array formula so do not enter the {}, instead enter
the forumla with CTRL+SHIFT+ENTER
In Cell C1
{=SUMPRODUCT(--($B2>$B$1:$B$4))+SUMPRODUCT(--($B2=$B$1:$B$4),--($A2>$A$1:$A$4))+SUMPRODUCT(--($B2=B$1:$B2),--($A2=A$1:$A2))}
Where there is a third criteria in column C that you want to use for the
sort,
Cell D1
{=SUMPRODUCT(--($B1>$B$1:$B$4))+SUMPRODUCT(--($B1=$B$1:$B$4),--($A1>$A$1:$A$4))+SUMPRODUCT(--($B1=$B$1:$B$4),--($A1=$A$1:$A$4),--($C1>$C$1:$C$4))+SUMPRODUCT(--($B1=B1:$B$1),--($A1=A1:$A$1),--($C1=C1:$C$1))}
StephenT replied to מיכאל (מיקי) אבידן
Thanks Micky, I really want this to work - as it is so simple - but
unfortunately does not appear to sort between repeated rankings.
StephenT replied to T. Valko
Thanks Valko, but Bernd's formula below works a treat and only requires one
column.
cheers
s
Regular Joe replied to Bernd P
Bernd, you are sooo clever! :)
T. Valko replied to StephenT
Ok, good deal.
--
Biff
Microsoft Excel MVP
Bernd P replied to StephenT
Hello Stephen,
Thanks for your feedback and for your suggestions.
The Sumproduct formula does not need to be entered as an array
formula, though. If somebody wants to cut a corner he might want to
array-enter the later index formulae which refer to the "rank" cells.
I have uploaded a sample file. The link is mentioned on the page I
provided.
Regards,
Bernd
Bernd P replied to Regular Joe
Then do not be an idiot, Joe :-)
Regular Joe replied to Bernd P
Funny, but the joke's on you:
http://sulprobil.com/html/excel_newsgroups.html
Hey what do I know I am just an idiot, right:)
T. Valko replied to Regular Joe
Touché
--
Biff
Microsoft Excel MVP
Embed a 'match' statement in sumproduct? Excel Excel 2007 I am trying to help a coworker who wants to generate a few summary List of invalid product codes This formula works, but does not exclude the invalid products: = SUMPRODUCT(('Sheet 2'!$C$2:$C$60000 = 'Sheet 1'!$F7)*1, ('Sheet 2'!$I$2:$I I try to add a match statement, to exclude invalid products (multiply matches by zero): = SUMPRODUCT(('Sheet 2'!$C$2:$C$60000 = 'Sheet 1'!$F7)*1, ('Sheet 2'!$I$2:$I 0)*1) I cannot tell if there is a problem in my syntax, or if Sumproduct automatically thinks my match statement should be rows 2-60000 instead of 1-100, which it is not working how I'd expect. I welcome any suggestions! Thank you, Keith Excel Worksheet Discussions Microsoft Excel (1) Excel 2007 (1) SUMPRODUCT (1) ISERROR (1) MATCH (1) ISNA (1) Lifesavers (1
Filter in Microsoft Excel Excel Hi all, I am using microsoft excel 2000. I need help in filtering the data. I have two columns as below Name follows. b How we will define this filter. Please help me. . . . Thanx for reading. Robin Excel Worksheet Discussions Microsoft Excel (1) SUMPRODUCT (1) COUNTIF (1) OFFSET (1) COLUMN (1) VBA (1) À´ªàµà´¤àµ
Sumproduct Problem Excel = SUMPRODUCT(- -(M21:M5127 = "a")*(N21:N5127 = "f")*(L21:L5127 = "FALSE")) This formula does not work, but I think it should. Any suggestions? Thanks Excel Discussions Microsoft Excel (1) SUMPRODUCT (1) TEXT (1) Booleans (1) Insead (1) Are those Booleans in L21:L5127? If so you need to remove the quotes. Try one of these. . . For Boolean FALSE: = SUMPRODUCT(- -(M21:M5127 = "a"), - -(N21:N5127 = "f"), - -(L21:L5127 = FALSE)) For TEXT false: = SUMPRODUCT(- -(M21:M5127
Help with Excel Excel I have a spreadsheet with 3 columns - I want to know the number of times and col b = textb and col c = text c. how do I do this in excel? Excel Miscellaneous Discussions Microsoft Excel (1) Excel 2007 (1) Excel (1) SUMPRODUCT (1) COUNTIF (1) Bliengme (1) Times (1) Texta (1) = sumproduct(- -(a1:a10 = "texta
countif two corresponding cells meet the criteria Excel how do you countif . . . if range 1 = "A" and range 2 = "B" Excel Worksheet Discussions Microsoft Excel (1) Excel 2007 (1) Excel (1) SUMPRODUCT (1) COUNTIFS (1) Try one of these. All versions of Excel: = SUMPRODUCT(- -(A1:A10 = "A"), - -(B1:B10 = "B")) Excel 2007 only: = COUNTIFS(A1:A10, "A", B1