Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Henrik
 
Posts: n/a
Default Building list based on condition

Does anyone have any suggestions as to how to build a function that
automatically selects the next observation with a particular value assigned
to it?

For instance, I have a dataset that looks like this (where column A contains
a list of names and column B contains a corresponding value/toggle that can
be either TRUE or FALSE):

Apple TRUE
Banana TRUE
Lemon TRUE
Orange FALSE
Grapefruit TRUE


As the desired function is dragged down, it will only select observations
with a TRUE VALUE in column B. The result would be the following list of
names. If the Lemon toggle was changed to FALSE, the list would no longer
contain Lemon.


Apple
Banana
Lemon
Grapefruit



Thanks,
Henrik
  #2   Report Post  
RagDyer
 
Posts: n/a
Default

If I understand what you're looking for, enter this in C1, and drag down to
copy as needed:

=IF(B1,A1,"")
--

HTH,

RD
==============================================
Please keep all correspondence within the Group, so all may benefit!
==============================================


"Henrik" wrote in message
...
Does anyone have any suggestions as to how to build a function that
automatically selects the next observation with a particular value assigned
to it?

For instance, I have a dataset that looks like this (where column A contains
a list of names and column B contains a corresponding value/toggle that can
be either TRUE or FALSE):

Apple TRUE
Banana TRUE
Lemon TRUE
Orange FALSE
Grapefruit TRUE


As the desired function is dragged down, it will only select observations
with a TRUE VALUE in column B. The result would be the following list of
names. If the Lemon toggle was changed to FALSE, the list would no longer
contain Lemon.


Apple
Banana
Lemon
Grapefruit



Thanks,
Henrik

  #3   Report Post  
Max
 
Posts: n/a
Default

One way to set it up

Assuming the data below is
in Sheet1, cols A and B, in row2 down

Apple TRUE
Banana TRUE
Lemon TRUE
Orange FALSE
Grapefruit TRUE


Use an adjacent helper col C

Put in C1: =Sheet2!A1

Put in C2: =IF(B2="","",IF(B2=$C$1,ROW(),""))

Copy C2 down to say, C1000
to cover max expected data in cols A and B

In Sheet2
-----------
Let's make a DV to select TRUE or FALSE in A1

Select A1
Click Data Validation
Settings:
Select under "Allow:" : List
Put in "Source:" : TRUE, FALSE
Click OK

Now put in A2:

=IF(ISERROR(SMALL(Sheet1!C:C,ROWS($A$1:A1))),"",IN DEX(Sheet1!A:A,MATCH(SMALL
(Sheet1!C:C,ROWS($A$1:A1)),Sheet1!C:C,0)))

Copy A2 down to A1000
(cover the same range size in Sheet1)

Col A will return all the items from Sheet1
where col B's toggle is set to
what's chosen in the DV in A1 (in Sheet2)

For the sample data in Sheet1,
assuming the DV in A1 is set to: TRUE
you'll get:

Apple
Banana
Lemon
Grapefruit

(rest are blanks:"")

If A1 is set to: FALSE, you'll get:
Orange

(rest are blanks:"")

--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----
"Henrik" wrote in message
...
Does anyone have any suggestions as to how to build a function that
automatically selects the next observation with a particular value

assigned
to it?

For instance, I have a dataset that looks like this (where column A

contains
a list of names and column B contains a corresponding value/toggle that

can
be either TRUE or FALSE):

Apple TRUE
Banana TRUE
Lemon TRUE
Orange FALSE
Grapefruit TRUE


As the desired function is dragged down, it will only select observations
with a TRUE VALUE in column B. The result would be the following list of
names. If the Lemon toggle was changed to FALSE, the list would no longer
contain Lemon.


Apple
Banana
Lemon
Grapefruit



Thanks,
Henrik



  #4   Report Post  
Aladin Akyurek
 
Posts: n/a
Default

Let A2:B7 house the sample you provided with labels in A2:B2...

{"Item","Flag";
"Apple",TRUE;
"Banana",TRUE;
"Lemon",TRUE;
"Orange",FALSE;
"Grapefruit",TRUE}

which says: A2 = Item, B2 = Flag, A3 = Apple, B3 = TRUE, etc.

C2 must house a 0.

In C3 enter & copy down:

=IF(B3=TRUE,LOOKUP(9.99999999999999E+307,$C$2:C2)+ 1,"")

In D1 enter:

=LOOKUP(9.99999999999999E+307,C:C)

In D2 enter: Result List

In D3 enter & copy down:

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

The area in from D3 on will show the desired result list.

Henrik wrote:
Does anyone have any suggestions as to how to build a function that
automatically selects the next observation with a particular value assigned
to it?

For instance, I have a dataset that looks like this (where column A contains
a list of names and column B contains a corresponding value/toggle that can
be either TRUE or FALSE):

Apple TRUE
Banana TRUE
Lemon TRUE
Orange FALSE
Grapefruit TRUE


As the desired function is dragged down, it will only select observations
with a TRUE VALUE in column B. The result would be the following list of
names. If the Lemon toggle was changed to FALSE, the list would no longer
contain Lemon.


Apple
Banana
Lemon
Grapefruit



Thanks,
Henrik

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
make a cell empty based on condition mpierre Charts and Charting in Excel 2 December 29th 04 01:01 PM
Selecting data from a list based on entered values GrantM Excel Discussion (Misc queries) 1 December 20th 04 10:59 AM
limit cell list selection based on the selection of another list lorraine Excel Worksheet Functions 2 December 14th 04 08:17 PM
Adding different validations based on condition Solis Excel Worksheet Functions 1 December 3rd 04 04:37 PM
Cannot sum values based on condition Ned Flanders Excel Worksheet Functions 1 December 3rd 04 04:36 AM


All times are GMT +1. The time now is 10:20 PM.

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"