INDIRECT with condition or FILTER formula

Dani_LobP

Board Regular
Joined
Aug 16, 2019
Messages
134
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I'm struggling to make some formula work, unsure if i am not applying the formula correctly.

for context:
I have a table that goes from C1 to GX. (x is dynamic since rows will be added over time)
First row is the headers of the table, so data goes from C2 until GX.
Then i have a column H, where will be Yes/No.

I want to be able to extract filtered rows into another tab from that table, ONLY when there is a Yes in the column H. But without adding column H if that was not clear.

When i do
Excel Formula:
=INDIRECT("Sheet1!C2:G"&COUNTA(Sheet1!C:C))
I am able to obtain the table as expected.
*I added COUNTA so the GX will be basically taking each new row and avoid having to enter a number each time...

The thing now is when i try to modify the above formula, with the filter condition.

If i do just:
Excel Formula:
=FILTER(Sheet1!C7:G10,H7:H10="Yes","")
I would be getting empty results. Unsure why.

And the idea that I want to try, is combine INDIRECT and FILTER, but when I do, I get VALUE error.

Not sure if i should FILTER(INDIRECT ... or INDIRECT(FILTER ... but get VALUE error both ways.

Excel Formula:
=FILTER(INDIRECT("Sheet1!C2:G"&COUNTA(Sheet1!C:C)),Sheet1!H:H="Yes")
Excel Formula:
=INDIRECT(FILTER("Sheet1!C2:G"&COUNTA(Sheet1!C:C),Sheet1!H:H="Yes"))

Hope it makes sense and someone can help me understand the formula better.

Thanks in advance!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
This formula
Excel Formula:
=FILTER(Sheet1!C7:G10,H7:H10="Yes","")
Will only return empty cells if you have "Yes" in col H on blank rows.
Can you post some sample data that shows the problem.
 
Upvote 0
Also when you mention 'Table', do you have a table object on the sheet or just some data in cells?
 
Upvote 0
This formula
Excel Formula:
=FILTER(Sheet1!C7:G10,H7:H10="Yes","")
Will only return empty cells if you have "Yes" in col H on blank rows.
Can you post some sample data that shows the problem.
Thanks for the prompt reply Fluff!
I'm not able to upload excel file with the real data. But I can replicate with some mock up data if that helps.

CDEFGHI
NameCountryDateTeamLinkConfirmed?Date2
Example1C122/08/23Team1URLYes
Example2C118/07/23Team2URL2No
Example3C215/08/23Team2URL3Yes

So technically, I should be getting a new table in different sheet, where i would have as per below:

CDEFG
NameCountryDateTeamLink
Example1C122/08/23Team1URL
Example3C215/08/23Team2URL3

If I use IDIRECT formula, it works fine, as i would be getting it all, but, that's when i want to include the FILTER, to just get the rows with a Yes. Not sure if FILTER alone do the same job as INDIRECT thou, that's why I'm not sure if combining them is making some error of understanding.

Eventually the formula to filter data from first table, that is in another sheet, would bring just the columns from C to G, and would be just bringing those with H having a Yes. (actually will end up being those with a Yes in column H and empty cell in column I, but i thought once I would understand how to add condition i would be able to replicate to add more columns if required).

Hope this makes more sense now.

Thanks!
 
Upvote 0
Also when you mention 'Table', do you have a table object on the sheet or just some data in cells?
Actually is a table as an object, but for some reason i was getting also error if using the table link instead of the column ... not sure why
 
Upvote 0
Just noticed the problem, you have not included the sheet name for col H, it Should be
Excel Formula:
=FILTER(Sheet1!C7:G10,Sheet1!H7:H10="Yes","")
 
Upvote 1
Solution
If working with tables then two options below:
Book1
CDEFGHIJKLMN
1NameCountryDateTeamLinkConfirmed?NameCountryDateTeamLink
2Example1C122/08/2023Team1URLYesExample1C145160Team1URL
3Example2C118/07/2023Team2URL2NoExample3C245153Team2URL3
4Example3C215/08/2023Team2URL3Yes
5
6
7NameCountryDateTeamLinkConfirmed?NameCountryDateTeamLink
8Example1C122/08/2023Team1URLYesExample1C145160Team1URL
9Example2C118/07/2023Team2URL2NoExample3C245153Team2URL3
10Example3C215/08/2023Team2URL3Yes
Sheet1
Cell Formulas
RangeFormula
J2:N3J2=FILTER(Table1[[Name]:[Link]],Table1[Confirmed?]="Yes")
J8:N9J8=DROP(FILTER(Table2,Table2[Confirmed?]="Yes"),,-1)
Dynamic array formulas.


This will remove the need for COUNTA or knowing the size of the range as formula will adjust to the table size.
 
Upvote 1
Just noticed the problem, you have not included the sheet name for col H, it Should be
Excel Formula:
=FILTER(Sheet1!C7:G10,Sheet1!H7:H10="Yes","")
oh. right. makes sense.
So i actually dont have to use INDIRECT since FILTER does the same thing actually. right?
if i have the Table1, i can actually select the header columns instead of the C:G with numbers, right?
And last question, if i want to add another condition, i can just add (condition1)*(condition2) , right?

Thanks again for your help!
 
Upvote 0
If working with tables then two options below:
Book1
CDEFGHIJKLMN
1NameCountryDateTeamLinkConfirmed?NameCountryDateTeamLink
2Example1C122/08/2023Team1URLYesExample1C145160Team1URL
3Example2C118/07/2023Team2URL2NoExample3C245153Team2URL3
4Example3C215/08/2023Team2URL3Yes
5
6
7NameCountryDateTeamLinkConfirmed?NameCountryDateTeamLink
8Example1C122/08/2023Team1URLYesExample1C145160Team1URL
9Example2C118/07/2023Team2URL2NoExample3C245153Team2URL3
10Example3C215/08/2023Team2URL3Yes
Sheet1
Cell Formulas
RangeFormula
J2:N3J2=FILTER(Table1[[Name]:[Link]],Table1[Confirmed?]="Yes")
J8:N9J8=DROP(FILTER(Table2,Table2[Confirmed?]="Yes"),,-1)
Dynamic array formulas.
Thanks! this could help a lot too!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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