List if conditions met

ddub25

Well-known Member
Joined
Jan 11, 2007
Messages
617
Office Version
  1. 2019
Platform
  1. Windows
Code:
A	B	C
1	ON	1
2	OFF	3
3	ON	4
4	ON	
5	OFF	
6	OFF	
7	OFF	
8	OFF	
9	OFF	
10	OFF

Column A is a list of numbers that are either turned ON or OFF.

Column B indicates whether they are turned ON or OFF. As you can see, numbers 1, 3 and 4 are turned ON.

Column C lists the numbers that are currently turned ON. Can anyone help with a formula for Column C that will list these numbers that are turned ON in a consecutive manner?
 
Last edited:

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
maybe something like...

=IFERROR(INDEX($A$1:$A$10,AGGREGATE(15,6,$A$1:$A$10/($B$1:$B$10="on"),ROWS($C$1:C1))),"")
 
Upvote 0
It must be equating to an error when I use that formula as all cells in Column C are empty. Any ideas why it is not outputting 1,3 and 4 in C1, C2, C3 respectively?
 
Upvote 0
not sure what the issue might be because its working for me...

C2=IFERROR(INDEX($A$1:$A$10,AGGREGATE(15,6,$A$1:$A$10/($B$1:$B$10="on"),ROWS($C$1:C1))),"")


you can try using

=IFERROR(INDEX($A$1:$A$10,SMALL(IF($B$1:$B$10="ON",ROW($A$1:$A$10)-ROW($A$1)+1),ROWS($D$1:D1))),"") control shift enter

as an alternative

Row\Col
A​
B​
C​
1​
1ON
1​
2​
2OFF
3​
3​
3ON
4​
4​
4ON
5​
5OFF
6​
6OFF
7​
7OFF
8​
8OFF
9​
9OFF
10​
10OFF

<tbody>
</tbody>
 
Upvote 0
Thanks Weazel, the 2nd formula seems to solve my problem.
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,854
Members
449,051
Latest member
excelquestion515

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