If you are using MS365
then you could make the above formula shorter using LET() and SEQUENCE()
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/ZvPhz.png)
For Older Version of Excel -->
• Formula used in cell G5
=MATCH(1,IF(SUBTOTAL(3,OFFSET(Sheet1!$A$2:$A$7,
ROW(Sheet1!$A$2:$A$7)-ROW(Sheet1!$A$2),0,1))>0,
IF(Sheet1!$A$2:$A$7=Sheet1!F5,1)),0)
Or, In MS365
• Formula used in cell G6
=LET(α,Sheet1!A2:A7,MATCH(1,IF(SUBTOTAL(3,OFFSET(α,SEQUENCE(ROWS(α))-1,0,1))>0,IF(α=F5,1)),0))
- So basically, what I am trying to achieve using the SUBTOTAL() function is to get the list of values which are not hidden or filtered out, in the following function the
3
denotes the COUNTA() while OFFSET() helps in creating a dynamic range. The following screenshot and the formula will give you a clear idea. Also since I am on MS365
hence dont require to hit CTRL+SHIFT+ENTER, but older versions needs to hit.
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/QKgrw.png)
=SUBTOTAL(3,OFFSET(Sheet1!$A$2:$A$7,ROW(Sheet1!$A$2:$A$7)-ROW(Sheet1!$A$2),0,1))
The above is same as
=SUBTOTAL(3,OFFSET(α,SEQUENCE(ROWS(α))-1,0,1))
Where α
is the range Sheet1!A2:A7
- From the above screenshot, its seen that, the one which is filtered out i.e.
2
shows as 0
, because those which are found are the 1
s, when this part of the formula is evaluated it shows as all FALSE
since it cant find the matching value here 2
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/I5zkM.png)
- Hence, when wrapping within MATCH() to get all the
TRUE
i.e. 1
s we are getting #N/A since it cant find it.
But if we try to find some other values, it will give us the required output by showing the row position. The logic applied goes same for other versions as well as for LibreOffice
as well.
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/LGIxn.png)
Now the check by the questioner for the German Libre Office (works):
- Go to
G5
.
- Paste
VERGLEICH(1;WENN(TEILERGEBNIS(3;VERSCHIEBUNG($A$2:$A$7;ZEILE($A$2:$A$7)-ZEILE($A$2);0;1))>0;WENN($A$2:$A$7=F5;1));0)
.
- Press
Ctrl
+Shift
+Enter
.
- See the matrix (
{}
) function {=VERGLEICH(1;WENN(TEILERGEBNIS(3;VERSCHIEBUNG($A$2:$A$7;ZEILE($A$2:$A$7)-ZEILE($A$2);0;1))>0;WENN($A$2:$A$7=F5;1));0)}
:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/5ePzJ.png)
And to understand the main trick, here is how the subtotals work in the matrix:
- Mark
G7
to G12
(or any other 5 empty cells below each other).
- Press
F2
while the 5 cells are marked.
- You will now be in the first cell of the 5 cells.
- Paste
TEILERGEBNIS(3;VERSCHIEBUNG($A$2:$A$7;ZEILE($A$2:$A$7)-ZEILE($A$2);0;1))
.
- Press
Ctrl
+Shift
+Enter
.
- See the matrix of the 5 cells filled with
0
in G9
for the 2
:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/VgHFD.png)
#N/A
-->=MATCH(1,IF(SUBTOTAL(3,OFFSET(Sheet1!$A$2:$A$7,ROW(Sheet1!$A$2:$A$7)-ROW(Sheet1!$A$2),0,1))>0,IF(Sheet1!$A$2:$A$7=Sheet2!A1,1)),0)