shorten list formula

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hello, formula-gurus,

This is a bit over my head.
The table explains itself, I think.

Code:
NAMES        RESULT
John    1    John
Pete    0    Marc
Matt    0    Luke
Marc    1    Brian
Luke    1    Aladin
Brian   1	
Geoff   0	
Aladin  1

is it possible to generate a shortened list with all names followed by a "1" ?

kind regards,
Erik
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
gave you one anyway:
Book1
ABCDE
1
2NAMESFlagList
3John11John
4Pete02Marc
5Matt03Luke
6Marc14Brian
7Luke15Aladin
8Brian16 
9Geoff07 
10Aladin18 
11
Sheet1


formula is:

=IF(D3<=COUNTIF($B$3:$B$10,1),INDEX($A$3:$A$10,SMALL(IF($B$3:$B$10=1,ROW($B$3:$B$10)-ROW($B$3)+1,ROW($B$10)+1),D3)),"")

...array entered with control + shift + enter, not just enter.
 
Upvote 0
erik.van.geit said:
Hello, formula-gurus,

This is a bit over my head.
The table explains itself, I think.

Code:
NAMES        RESULT
John    1    John
Pete    0    Marc
Matt    0    Luke
Marc    1    Brian
Luke    1    Aladin
Brian   1	
Geoff   0	
Aladin  1

is it possible to generate a shortened list with all names followed by a "1" ?

kind regards,
Erik

Two methods: One I have been posting for the purpose you want and its many variations and another which gets posted on worksheet.functions, often in a non-robust form. The first is fast, the second is slow and is only needed under specific conditions...
Book3
ABCDEFGHI
10Cond:155
2NAMESFLAGIDXRESULTRESULT
3John11JohnJohn
4Pete0 MarcMarc
5Matt0 LukeLuke
6Marc12BrianBrian
7Luke13AladinAladin
8Brian14  
9Geoff0   
10Aladin15 
11
Sheet1


Method 1

C1 must house a 0.

C3, copied down:

=IF(B3<>"",IF(B3=$F$1,LOOKUP(9.99999999999999E+307,$C$1:C2)+1,""),"")

F1 specifies the condition.

G1:

=LOOKUP(9.99999999999999E+307,C1:C10)

calculates the number of items that meet the flag condition.

G3, copied down:

=IF(ROW()-ROW($G$3)+1<=$G$1,LOOKUP(ROW()-ROW($G$3)+1,$C$3:$C$10,$A$3:$A$10),"")

yields the desired result list.

Method 2

I1:

=SUM(B3:B10)

I3:

=IF(ROW()-ROW($I$3)+1<=$I$1,INDEX($A$3:$A$10,SMALL(IF($B$3:$B$10=$F$1,ROW($B$3:$B$10)-ROW($B$3)+1),ROW()-ROW($I$3)+1)),"")

which is confirmed with control+shift+enter then copied down yields the desired result list.
 
Upvote 0
PaddyD,
thank you for reponse :)

I'm trying but don't see the link between Chips page (I already saw before) and this problem. Perhaps I'm blind now, where should I look?
...like an example?
do you mean you would provide an example ?
then my answer would be: "YES, please" :p
kind regards,
Erik
 
Upvote 0
Hi Erik,

Use Advanced Filter.

Have a look..
Book1
ABCDEFG
1NAMESFLAGNAMESFLAG
2John1TRUEJohn1
3Pete0Marc1
4Matt0Luke1
5Marc1Brian1
6Luke1Aladin1
7Brian1List RangeA1:B9
8Geoff0Criteria RangeD1:D2
9Aladin1Copy to:F1
Sheet2


Formula in D2,

=B2=1

HTH
 
Upvote 0
Thanks, Paddy and Aladin!
We posted almost at the same time.

intresting to study how things work not only concerning acurateness but also speed

Thank you, Krishnakumar,
I really need a formula for a "permanent" solution.
You provided a clear example of the use of advanced filter.

kind regards to you all!
Erik
 
Upvote 0
Erik

Assuming that your data is in the range A1:B9 then put a space in B10.

In C2 array enter
Code:
=INDEX($A$1:$A$10,SMALL(IF($B$2:$B$9=1,ROW($B$2:$B$9),10),ROW()-1))

and copy down.


Tony
 
Upvote 0
acw said:
Erik

Assuming that your data is in the range A1:B9 then put a space in B10.

In C2 array enter
Code:
=INDEX($A$1:$A$10,SMALL(IF($B$2:$B$9=1,ROW($B$2:$B$9),10),ROW()-1))

and copy down.


Tony

That's a non-robust form of the array method (Method 2) I was talking about.
 
Upvote 0

Forum statistics

Threads
1,215,299
Messages
6,124,125
Members
449,142
Latest member
championbowler

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