Filter in multiple areas

kalda

New Member
Joined
May 25, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hello to all,

Im strugling to solve this for a week now. I would like to create filter something like: =FILTER(I4:I97,(J23:J40="PN")+(J42:J59="PN")+(J61:J78="N")+(J80:J97="N"),"") but always with error. This is just an example, I already tryed multiple variants of this, but still with some error in the end. Sofar I figured out, that this function is not supported in Excel like this (criteria in multiple areas), therefore Im asking here for help. Do you know some workaround? Maybe user defined function will help, but I know nothing about VBA.
And sorry for my English, Im not native speaker.

Thank you all.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Welcome to the Board!

I think you need to filter each section separately, but you should be able to combine them all into one list by using the VSTACK function, i.e.
Excel Formula:
=VSTACK(FILTER(...),FILTER(...),FILTER(...),FILTER(...))

See: VSTACK Function

If that is not what you are looking for, then I probably do not understand your question, in which case it would be helpful to post what your data looks like and expected results.
MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 1
Thank you for your answer, I already tried this, but if one or more filters comes empty (which is expected), or with error, it will create empty ("") cell, which can then affect the cells under the filter array leading to #SPILL! error (houpfly this is correct translation)
 
Upvote 0
I think you need to show us an example of your data, and exactly what you expected output based on that example needs to look like.
 
Upvote 0
So, this is my current sheet:

Plachta nová testovací.xlsx
IJK
2POUT
31.2.
4Name 1NN
5Name 2NN
6Name 3NN
7Name 4NN
8Name 5NN
9Name 6NN
10Name 7NN
11Name 8NN
12Name 9NN
13Name 10ŘDN
14Name 11NN
15
16
17
18
19
20
21
22OCCUPANCY:1212
23Name 12
24Name 13
25Name 14
26Name 15REC
27Name 16PD
28Name 17PN
29Name 18PN
30Name 19
31Name 20
32Name 21
33
34
35
36
37
38
39
40
41OCCUPANCY:
42Name 22PNPN
43Name 23HOTPD
44Name 24
45Name 25PD
46Name 26
47Name 27PD
48Name 28PDPD
49Name 29
50Name 30PD
51Name 31
52Name 32
53
54
55
56
57
58
59
60OCCUPANCY:
61Name 33DD
62Name 34DD
63Name 35DREC
64Name 36DD
65Name 37DD
66Name 38DD
67Name 39DD
68Name 40SICKSICK
69Name 41DD
70Name 42DD
71
72
73
74
75
76
77
78
79OCCUPANCY:1212
80Name 43
81Name 44ŘD
82Name 45
83Name 46
84Name 47
85Name 48
86Name 49
87Name 50
88Name 51
89Name 52
90Name 53
91Name 54
92Name 55
93
94
95
96
97
98OCCUPANCY:00
List1
Cell Formulas
RangeFormula
J2:K2J2=IF(WEEKDAY(J3,2)=1,"PO",IF(WEEKDAY(J3,2)=2,"UT",IF(WEEKDAY(J3,2)=3,"ST",IF(WEEKDAY(J3,2)=4,"CT",IF(WEEKDAY(J3,2)=5,"PA",IF(WEEKDAY(J3,2)=6,"SO","NE"))))))
K3K3=J3+1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J98:X98Other TypeIcon setNO
J80:X97,J23:X40,J42:X59,J61:X78,J4:X21Cell Value="SD"textNO
J80:X97,J23:X40,J42:X59,J61:X78,J4:X21Cell Value="NV"textNO
J80:X97,J23:X40,J42:X59,J61:X78,J4:X21Cell Value="HOT"textNO
J80:X97,J23:X40,J42:X59,J61:X78,J4:X21Cell Value="AKCE"textNO
J80:X97,J23:X40,J42:X59,J61:X78,J4:X21Cell Value="ŘD"textNO
J80:X97,J23:X40,J42:X59,J61:X78,J4:X21Cell Value="REC"textNO
J80:X97,J23:X40,J42:X59,J61:X78,J4:X21Cell Value="SICK"textNO
J80:X97,J23:X40,J42:X59,J61:X78,J4:X21Cell Value="PD"textNO
J80:X97,J23:X40,J42:X59,J61:X78,J4:X21Cell Value="PN"textNO


And this is what I would like to get after the FILTER formula is implemented:

Plachta nová testovací.xlsx
IJK
2POUT
31.2.
4Name 1NN
5Name 2NN
6Name 3NN
7Name 4NN
8Name 5NN
9Name 6NN
10Name 7NN
11Name 8NN
12Name 9NN
13Name 10ŘDN
14Name 11NN
15Name 17Name 22
16Name 18
17Name 22
18
19
20
21
22OCCUPANCY:1212
23Name 12
24Name 13
25Name 14
26Name 15REC
27Name 16PD
28Name 17PN
29Name 18PN
30Name 19
31Name 20
32Name 21
33
34
35
36
37
38
39
40
41OCCUPANCY:
42Name 22PNPN
43Name 23HOTPD
44Name 24
45Name 25PD
46Name 26
47Name 27PD
48Name 28PDPD
49Name 29
50Name 30PD
51Name 31
52Name 32
53
54
55
56
57
58
59
60OCCUPANCY:
61Name 33DD
62Name 34DD
63Name 35DREC
64Name 36DD
65Name 37DD
66Name 38DD
67Name 39DD
68Name 40SICKSICK
69Name 41DD
70Name 42DD
71Name 27Name 16
72Name 28Name 23
73Name 30Name 25
74Name 28
75
76
77
78
79OCCUPANCY:1212
80Name 43
81Name 44ŘD
82Name 45
83Name 46
84Name 47
85Name 48
86Name 49
87Name 50
88Name 51
89Name 52
90Name 53
91Name 54
92Name 55
93
94
95
96
97
List1
Cell Formulas
RangeFormula
J2:K2J2=IF(WEEKDAY(J3,2)=1,"PO",IF(WEEKDAY(J3,2)=2,"UT",IF(WEEKDAY(J3,2)=3,"ST",IF(WEEKDAY(J3,2)=4,"CT",IF(WEEKDAY(J3,2)=5,"PA",IF(WEEKDAY(J3,2)=6,"SO","NE"))))))
K3K3=J3+1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J80:X97,J23:X40,J42:X59,J61:X78,J4:X21Cell Value="SD"textNO
J80:X97,J23:X40,J42:X59,J61:X78,J4:X21Cell Value="NV"textNO
J80:X97,J23:X40,J42:X59,J61:X78,J4:X21Cell Value="HOT"textNO
J80:X97,J23:X40,J42:X59,J61:X78,J4:X21Cell Value="AKCE"textNO
J80:X97,J23:X40,J42:X59,J61:X78,J4:X21Cell Value="ŘD"textNO
J80:X97,J23:X40,J42:X59,J61:X78,J4:X21Cell Value="REC"textNO
J80:X97,J23:X40,J42:X59,J61:X78,J4:X21Cell Value="SICK"textNO
J80:X97,J23:X40,J42:X59,J61:X78,J4:X21Cell Value="PD"textNO
J80:X97,J23:X40,J42:X59,J61:X78,J4:X21Cell Value="PN"textNO


This is only 3 columns example.
The FILTER formula should be in cells J15, K15 (and so on) and J71, K71 (and so on).

In cell J15 should be filter setup so it will filter names from column I only if in areas J23:J40 or J42:J59 is "PN" or in areas J61:J78 or J80:J97 is "N".
In cell J71 should be filter setup so it will filter names from column I only if in areas J23:J40 or J42:J59 is "PD" or in areas J61:J78 or J80:J97 is "D".
I would like to have the formula with variable arrays.
 
Upvote 0
OK, looks like we just need to add in an IFERROR part to my formula, in case a particular filter doesn't return anything.
So the formula for J15 would look like this:
Rich (BB code):
=VSTACK(IFERROR(FILTER(I23:I32,J23:J32="PN"),""),IFERROR(FILTER(I42:I52,J42:J52="PN"),""),IFERROR(FILTER(I61:I70,J61:J70="PN"),""),IFERROR(FILTER(I80:I92,J80:J92="PN"),""))
I color-coded each separate filter within the VSTACK function so it can easily be seen. Just repeart this format for your other values.

Here is the result for cell J15:
1685447167976.png
 
Upvote 0
Thank you for your reply, after implementing this, VSTACK generate 2 empty cells (see attached image) which in this case isn´t problem, but definitly will be, when I will use it in other columns. Do you have some idea, how to get rid of them?

1685449968643.png
 
Upvote 0
Try this variation:
Rich (BB code):
=LET(x,VSTACK(IFERROR(FILTER(I23:I32,J23:J32="PN"),""),IFERROR(FILTER(I42:I52,J42:J52="PN"),""),IFERROR(FILTER(I61:I70,J61:J70="PN"),""),IFERROR(FILTER(I80:I92,J80:J92="PN"),"")),FILTER(x,x<>""))
The original part of the formula is in blue. I added the new stuff in red, putting it in a LET function, and filtering the results to filter out the blank values.
 
Upvote 0
Solution
You are welcome.
Glad I was able to help!

That is the first time I ever combined the new LET, VSTACK, and FILTER functions together in one formula, so it was a learning experience for me too!
:)
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
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