MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Selecting all values in a column that meet a criterion and returning the value from the same row in

Posted by Eric on May 25, 2001 7:53 AM

This is a different tack on an earlier thread.
Column (A) is a list of reference numbers that are relevant to the row numbers in another workbook.
Columns (B) through (O) are statistical test scores relevant to the row number referenced in column (A).
What I would like to do is find all of the values in each of columns (B) through (O) that reach a certain criterion (say >.5), and return the value of Column (A) for those numbers. I'd like the returned values to be "stacked" (that is with no intervening blank or empty cells between results within a column).

Posted by Aladin Akyurek on May 25, 2001 10:27 AM


Not sure whether I understand your query as intended.
I'll assume as a manageable set of data as example:


This set occupies F2:H7. Translated to your situation, you'll need to insert a number of columns such that your data also starts in F from F2 on.

In A1:A2 enter what follows:


In A3 enter: =COUNT(F:F)+1

In B2 enter: =IF(ROW()>$A$3,"",IF(SUM(OR($G$2:$G$7>$A$2,$H$2:$H$7>$A$2))>=1,F2,0)) [ copy down this as far as needed ]

In C2:C3 enter what follows:

{"List1";"List2"} [ just labels ]



In E2 array-enter: =IF(ROW()-ROW(INDIRECT($D$3))+1>ROWS(INDIRECT($D$2))-COUNTIF(INDIRECT($D$2),0),"",INDIRECT(ADDRESS(SMALL((IF(INDIRECT($D$2)<>0,ROW(INDIRECT($D$2)),ROW()+ROWS(INDIRECT($D$2)))),ROW()-ROW(INDIRECT($D$3))+1),COLUMN(INDIRECT($D$2))))) [ copy down this array formula as far as needed ]

In column B from B2 on, you see as result:


In column E from E2 on, you see, I hope, what you wanted:

{1;4;6;"";"";""} [ effectively: 1,4,6 ]



Posted by Eric on May 25, 2001 1:11 PM

Thanks and a second clarification


Thank you very much for your help. I'm not sure whether I understand my query either, LOL.
It seems as if you are pretty close in your design to what I was looking for with some exceptions that may not be worth discussing.

I followed your instructions and built a spreadsheet with the 'dummy' data. Unfortunately both Column (B) and Column (E) give me the same values
essentially the values from Column (F). Column (E) is also not blanking values <.5.

You've already put a lot into this and I'm sure I'll be able to put what you've shown me to good use, so thanks again, and there's certainly no need for you to pursue this further. However, if you are still interested, see below.

To clarify on my query (if only for morbid curiosity), let's say there are 4 columns (A,B,C,and D). Call Column (A) "Reference", call Column (B) "Stat result 1", Column (C) "Stat result 2", and Column (D) "Stat result 3". In each of the three "Stat" columns I am looking for values >.5. Each column has a fixed number of results/rows, but will have a variable number of results/rows >.5, and furthermore these values will occur at different rows for different columns. The output I want is the "reference" value from Column (A) for every row within each column at which there was a value >.5. Therefore the total number of output columns (call them "sig1", "sig2", and "sig3" should equal the number of "stat" columns (in this case 3) because I dont want the results from different columns "mixed".

I will attempt to describe the design with example data below:
columns: reference;stat1, stat2, stat3, sig1, sig2, sig3
2001,.1,.8,.4," ",5000," "
Thanks again for your attention

Posted by Aladin Akyurek on May 25, 2001 2:57 PM

Re: Thanks and a second clarification


Here is your data set. It occupies A1:D6.


In E1 enter: =IF(B$1:B$6>0.5,$A$1:$A$6,0)

Copy this across to G1 then down as far as needed.

Here is the result that you see in E1:G6.

[1] {1000,0,0;0,0,2112;0,2001,0;5000,5000,0;0,3000,0;0,0,8000}

In fact, the whole thing is similar to what I described in my first post. The only difference is that we now have 3 result columns, each of which must be further processed to get ("no mixing"):

[2] {1000,2001,2112;5000,3000,8000;" ",5000," "}

Since I described how this can be done in my first post, I leave it to you. One caveat though: you'll need at least one additional column to apply the array-formula of the previous post.

Maybe you can use a manual procedure to eliminate the cells with zeroes to get [2].

Note. You said you had some problems in implementing the proc of the previous post. I can send you the relevant workbook if you so desire.

================== ,

Posted by Eric on May 29, 2001 2:15 PM

plz send me the worksheet


Thanks again for your help, I'm still not getting through this quite right, so Id appreciate the worksheet if you get the time.

Posted by Eric on May 29, 2001 2:41 PM

Ignore previous post, I got it! (finally)

If I reversed the greater than symbol on this line
In B2 enter: =IF(ROW()>$A$3,"",IF(SUM(OR($G$2:$G$7>$A$2,$H$2:$H$7>$A$2))>=1,F2,0))
In B2 enter: =IF(ROW()<$A$3,"",IF(SUM(OR($G$2:$G$7>$A$2,$H$2:$H$7>$A$2))>=1,F2,0))
then everything comes out- thanks again for all the work!