Filter out the blanks and return cells with values only without VBA

GMC The Macro Man

Board Regular
Joined
Mar 23, 2023
Messages
104
Office Version
  1. 2021
Platform
  1. Windows
Hello team

I have a data sheet with student details and the scores for the subjects they chose. I need to filter the scores by subject on to different Tabs, however I need to filter out the blanks
In the example here the PupilData Tab details the User ID, Name, Year, Class and Subjects chosen with results
In the next 2 tabs (Design and Spanish) I have just cut n pasted for the purpose of this exercise the relevant data,
What I want to have is a formula that says - only return the rows that have data in the chosen subject column (col E). The 2 final tabs (Design_Yes and Spanish_Yes) are what I am looking for the output to be.
I can Use =FILTER(CHOOSE.. and chose the columns to return but this won't cut out the blanks.
Can any one assist with this.

Thanks as always

Mr Excel.xlsx
ABCDEFGHIJKLMNOPQRSTUVWX
1IDKnown AsYear GroupClassArt & DesignBusinessChemistryDanceDesignDramaEnglishFrenchGeographyGraphicsHistoryHuman BiologyItalianMathsModern StudiesMusicPE (SQA)PhysicsRE (SQA)Spanish
21001234ChaS44A174763
31001235SauS44A71755832
41001236MillS44B36651
51001237KatS44B15828572
61001238ImS44C3357151
71001239SoS44C663
81001240SeS44D786546
91001241NicS44D53326
101001242LucS44A5558444358
111001243JaS55A887226752
121001244JoS55B247362
131001245DaS55B72586584
141001246RaS55C876654
151001247LiS55C284483674
161001248PiS55D445166
171001249YeS55D48428832
181001250YangS66A22561552661
191001251TomS66A6528
201001252LizS66B6254134478
211001253George S66B4478542
PupilData


Mr Excel.xlsx
ABCDE
1IDKnown AsYear GroupClassDesign
21001234ChaS44A7
31001235SauS44A
41001236MillS44B
51001237KatS44B1
61001238ImS44C
71001239SoS44C
81001240SeS44D
91001241NicS44D3
101001242LucS44A5
111001243JaS55A
121001244JoS55B
131001245DaS55B
141001246RaS55C7
151001247LiS55C
161001248PiS55D
171001249YeS55D8
181001250YangS66A
191001251TomS66A
201001252LizS66B2
211001253George S66B
Design


Mr Excel.xlsx
ABCDE
1IDKnown AsYear GroupClassSpanish
21001234ChaS44A3
31001235SauS44A2
41001236MillS44B
51001237KatS44B
61001238ImS44C
71001239SoS44C
81001240SeS44D6
91001241NicS44D
101001242LucS44A8
111001243JaS55A
121001244JoS55B2
131001245DaS55B4
141001246RaS55C
151001247LiS55C
161001248PiS55D6
171001249YeS55D
181001250YangS66A1
191001251TomS66A
201001252LizS66B8
211001253George S66B2
Spanish


Mr Excel.xlsx
ABCDE
1IDKnown AsYear GroupClassDesign
21001234ChaS44A7
31001237KatS44B1
41001241NicS44D3
51001242LucS44A5
61001246RaS55C7
71001249YeS55D8
81001252LizS66B2
Design_Yes


Mr Excel.xlsx
ABCDE
1IDKnown AsYear GroupClassSpanish
21001234ChaS44A3
31001235SauS44A2
41001240SeS44D6
51001242LucS44A8
61001244JoS55B2
71001245DaS55B4
81001248PiS55D6
91001250YangS66A1
101001252LizS66B8
111001253George S66B2
Spanish_Yes
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Here is the solution for Design. Same solution applies to other subjects. I don't know what FILTER formula you were trying to use, but this is done with two FILTER formulas.

$scratch.xlsm
ABCDE
1IDKnown AsYear GroupClassDesign
21001234ChaS44A7
31001237KatS44B1
41001241NicS44D3
51001242LucS44A5
61001246RaS55C7
71001249YeS55D8
81001252LizS66B2
Design_Yes
Cell Formulas
RangeFormula
A1:D8A1=FILTER(PupilData!$A:$D,PupilData!$I:$I<>"")
E1:E8E1=FILTER(PupilData!$I:$I,PupilData!$I:$I<>"")
Dynamic array formulas.
 
Upvote 0
Solution
I came up with something similar to Jeff's solution. In Z1, if you select the class from the dropdown data validation, the filter should update just below it.

Book1.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACAD
1IDKnown AsYear GroupClassArt & DesignBusinessChemistryDanceDesignDramaEnglishFrenchGeographyGraphicsHistoryHuman BiologyItalianMathsModern StudiesMusicPE (SQA)PhysicsRE (SQA)SpanishHistory
21001234ChaS44A174763
31001235SauS44A71755832IDKnown AsYear GroupClassHistory
41001236MillS44B366511001237KatS44B2
51001237KatS44B158285721001242LucS44A4
61001238ImS44C33571511001245DaS55B6
71001239SoS44C6631001249YeS55D8
81001240SeS44D7865461001250YangS66A1
91001241NicS44D53326
101001242LucS44A5558444358
111001243JaS55A887226752
121001244JoS55B247362
131001245DaS55B72586584
141001246RaS55C876654
151001247LiS55C284483674
161001248PiS55D445166
171001249YeS55D48428832
181001250YangS66A22561552661
191001251TomS66A6528
201001252LizS66B6254134478
211001253George S66B4478542
Sheet2
Cell Formulas
RangeFormula
Z3:AD8Z3=LET(rng,A1:X21,filt_1,FILTER(rng,INDEX(rng,,MATCH(Z1,INDEX(rng,1,),))<>""),HSTACK(INDEX(filt_1,,1),INDEX(filt_1,,2),INDEX(filt_1,,3),INDEX(filt_1,,4),INDEX(filt_1,,MATCH(Z1,INDEX(filt_1,1,),0))))
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
Z1List=$E$1:$X$1


Doug
 
Upvote 2
I can Use =FILTER(CHOOSE.. and chose the columns to return but this won't cut out the blanks.
Are you saying that you would use CHOOSECOLS? If so, that would indicate that you are not using Excel 2021 as indicated in your profile. If you still need further help after what has been offered, can you please confirm the version(s) this needs to work in?

Below I have suggested formulas that can be used exactly the same on each 'subject' worksheet. The formula in A1 if you have the available functions in Excel 365, the formula in A11 if it has to work in Excel 2021. Check the Table name. I have hidden a few columns in this 'Pupil Data' sheet to keep the mini sheet a bit smaller for the forum.

GMC The Macro Man.xlsm
ABCDHIJOPQWX
1IDKnown AsYear GroupClassDanceDesignDramaHistoryHuman BiologyItalianRE (SQA)Spanish
21001234ChaS44A73
31001235SauS44A712
41001236MillS44B61
51001237KatS44B128
61001238ImS44C31
71001239SoS44C3
81001240SeS44D86
91001241NicS44D3
101001242LucS44A55458
111001243JaS55A76
121001244JoS55B2
131001245DaS55B264
141001246RaS55C7
151001247LiS55C883
161001248PiS55D16
171001249YeS55D488
181001250YangS66A2151
191001251TomS66A
201001252LizS66B2378
211001253George S66B42
Pupil Data


GMC The Macro Man.xlsm
ABCDE
1IDKnown AsYear GroupClassDesign
21001234ChaS44A7
31001237KatS44B1
41001241NicS44D3
51001242LucS44A5
61001246RaS55C7
71001249YeS55D8
81001252LizS66B2
9
10
11IDKnown AsYear GroupClassDesign
121001234ChaS44A7
131001237KatS44B1
141001241NicS44D3
151001242LucS44A5
161001246RaS55C7
171001249YeS55D8
181001252LizS66B2
19
Design
Cell Formulas
RangeFormula
A1:E8A1=LET(d,CHOOSECOLS(PupilData[#All],1,2,3,4,MATCH(TEXTAFTER(CELL("filename",A1),"]"),PupilData[#Headers],0)),FILTER(d,TAKE(d,,-1)<>""))
A11:E18A11=LET(fn,CELL("filename",A11),d,FILTER(PupilData[#All],ISNUMBER(SEARCH("|"&PupilData[#Headers]&"|","|ID|Known As|Year Group|Class|"&REPLACE(fn,1,FIND("]",fn),"")&"|"))),FILTER(d,INDEX(d,0,5)<>""))
Dynamic array formulas.


GMC The Macro Man.xlsm
ABCDE
1IDKnown AsYear GroupClassHuman Biology
21001243JaS55A6
31001247LiS55C8
41001248PiS55D1
51001252LizS66B3
6
7
8
9
10
11IDKnown AsYear GroupClassHuman Biology
121001243JaS55A6
131001247LiS55C8
141001248PiS55D1
151001252LizS66B3
16
Human Biology
Cell Formulas
RangeFormula
A1:E5A1=LET(d,CHOOSECOLS(PupilData[#All],1,2,3,4,MATCH(TEXTAFTER(CELL("filename",A1),"]"),PupilData[#Headers],0)),FILTER(d,TAKE(d,,-1)<>""))
A11:E15A11=LET(fn,CELL("filename",A11),d,FILTER(PupilData[#All],ISNUMBER(SEARCH("|"&PupilData[#Headers]&"|","|ID|Known As|Year Group|Class|"&REPLACE(fn,1,FIND("]",fn),"")&"|"))),FILTER(d,INDEX(d,0,5)<>""))
Dynamic array formulas.
 
Upvote 1
Here is the solution for Design. Same solution applies to other subjects. I don't know what FILTER formula you were trying to use, but this is done with two FILTER formulas.

$scratch.xlsm
ABCDE
1IDKnown AsYear GroupClassDesign
21001234ChaS44A7
31001237KatS44B1
41001241NicS44D3
51001242LucS44A5
61001246RaS55C7
71001249YeS55D8
81001252LizS66B2
Design_Yes
Cell Formulas
RangeFormula
A1:D8A1=FILTER(PupilData!$A:$D,PupilData!$I:$I<>"")
E1:E8E1=FILTER(PupilData!$I:$I,PupilData!$I:$I<>"")
Dynamic array formulas.
Hi Jeff, Many thanks for your help here on this and my apologies for the lateness on the response as I'm just back from holiday.
 
Upvote 0
I came up with something similar to Jeff's solution. In Z1, if you select the class from the dropdown data validation, the filter should update just below it.

Book1.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACAD
1IDKnown AsYear GroupClassArt & DesignBusinessChemistryDanceDesignDramaEnglishFrenchGeographyGraphicsHistoryHuman BiologyItalianMathsModern StudiesMusicPE (SQA)PhysicsRE (SQA)SpanishHistory
21001234ChaS44A174763
31001235SauS44A71755832IDKnown AsYear GroupClassHistory
41001236MillS44B366511001237KatS44B2
51001237KatS44B158285721001242LucS44A4
61001238ImS44C33571511001245DaS55B6
71001239SoS44C6631001249YeS55D8
81001240SeS44D7865461001250YangS66A1
91001241NicS44D53326
101001242LucS44A5558444358
111001243JaS55A887226752
121001244JoS55B247362
131001245DaS55B72586584
141001246RaS55C876654
151001247LiS55C284483674
161001248PiS55D445166
171001249YeS55D48428832
181001250YangS66A22561552661
191001251TomS66A6528
201001252LizS66B6254134478
211001253George S66B4478542
Sheet2
Cell Formulas
RangeFormula
Z3:AD8Z3=LET(rng,A1:X21,filt_1,FILTER(rng,INDEX(rng,,MATCH(Z1,INDEX(rng,1,),))<>""),HSTACK(INDEX(filt_1,,1),INDEX(filt_1,,2),INDEX(filt_1,,3),INDEX(filt_1,,4),INDEX(filt_1,,MATCH(Z1,INDEX(filt_1,1,),0))))
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
Z1List=$E$1:$X$1


Doug
Thanks Doug for your input, however I had already used Jeff's solution to complete the report but I will certainly hold on to your idea as well. I'm just back from holiday and that's why it has taken so long to respond. George
 
Upvote 0
Are you saying that you would use CHOOSECOLS? If so, that would indicate that you are not using Excel 2021 as indicated in your profile. If you still need further help after what has been offered, can you please confirm the version(s) this needs to work in?

Below I have suggested formulas that can be used exactly the same on each 'subject' worksheet. The formula in A1 if you have the available functions in Excel 365, the formula in A11 if it has to work in Excel 2021. Check the Table name. I have hidden a few columns in this 'Pupil Data' sheet to keep the mini sheet a bit smaller for the forum.

GMC The Macro Man.xlsm
ABCDHIJOPQWX
1IDKnown AsYear GroupClassDanceDesignDramaHistoryHuman BiologyItalianRE (SQA)Spanish
21001234ChaS44A73
31001235SauS44A712
41001236MillS44B61
51001237KatS44B128
61001238ImS44C31
71001239SoS44C3
81001240SeS44D86
91001241NicS44D3
101001242LucS44A55458
111001243JaS55A76
121001244JoS55B2
131001245DaS55B264
141001246RaS55C7
151001247LiS55C883
161001248PiS55D16
171001249YeS55D488
181001250YangS66A2151
191001251TomS66A
201001252LizS66B2378
211001253George S66B42
Pupil Data


GMC The Macro Man.xlsm
ABCDE
1IDKnown AsYear GroupClassDesign
21001234ChaS44A7
31001237KatS44B1
41001241NicS44D3
51001242LucS44A5
61001246RaS55C7
71001249YeS55D8
81001252LizS66B2
9
10
11IDKnown AsYear GroupClassDesign
121001234ChaS44A7
131001237KatS44B1
141001241NicS44D3
151001242LucS44A5
161001246RaS55C7
171001249YeS55D8
181001252LizS66B2
19
Design
Cell Formulas
RangeFormula
A1:E8A1=LET(d,CHOOSECOLS(PupilData[#All],1,2,3,4,MATCH(TEXTAFTER(CELL("filename",A1),"]"),PupilData[#Headers],0)),FILTER(d,TAKE(d,,-1)<>""))
A11:E18A11=LET(fn,CELL("filename",A11),d,FILTER(PupilData[#All],ISNUMBER(SEARCH("|"&PupilData[#Headers]&"|","|ID|Known As|Year Group|Class|"&REPLACE(fn,1,FIND("]",fn),"")&"|"))),FILTER(d,INDEX(d,0,5)<>""))
Dynamic array formulas.


GMC The Macro Man.xlsm
ABCDE
1IDKnown AsYear GroupClassHuman Biology
21001243JaS55A6
31001247LiS55C8
41001248PiS55D1
51001252LizS66B3
6
7
8
9
10
11IDKnown AsYear GroupClassHuman Biology
121001243JaS55A6
131001247LiS55C8
141001248PiS55D1
151001252LizS66B3
16
Human Biology
Cell Formulas
RangeFormula
A1:E5A1=LET(d,CHOOSECOLS(PupilData[#All],1,2,3,4,MATCH(TEXTAFTER(CELL("filename",A1),"]"),PupilData[#Headers],0)),FILTER(d,TAKE(d,,-1)<>""))
A11:E15A11=LET(fn,CELL("filename",A11),d,FILTER(PupilData[#All],ISNUMBER(SEARCH("|"&PupilData[#Headers]&"|","|ID|Known As|Year Group|Class|"&REPLACE(fn,1,FIND("]",fn),"")&"|"))),FILTER(d,INDEX(d,0,5)<>""))
Dynamic array formulas.
Hi Peter, thanks for the reply and I am using Office Pro Plus 2021 and I know that I have used the =Filter(Choosecols... function as I'm not great on the LET formulas. As to which version I need to use this on I'm positive my end users will be on 365 so I will certainly look at your solutions. I'm just back from a late summer holiday break and thats why it has taken this long to respond. Thanks again, George
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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