last missing number

excelNewbie22

Well-known Member
Joined
Aug 4, 2021
Messages
510
Office Version
  1. 365
Platform
  1. Windows
hi,
how can i tell the last one missing number from a fixed range, say 1 to 42, without knowing the range of rows? (only from where to check=starting point, like o2:t _)
see example below

test
OPQRSTU
1last missing number
2123456
3789101112
4131415161718
5192021222324
6252627282930
7313233343536
81373839404142
9252627282930
10
11
12123456
13789101112
14131415161718
15192021222324
16252627282930
17313233343536
18279111315
1935373940414238
20131415161718
21
22
23234567
24789101112
25131415161718
26192021222324
27252627282930
28313233343536
29373839404142
305711222535
31589101112
321012132223241
33192021222324
34252627282930
35313233343536
test
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Like this?

23 07 24.xlsm
OPQRSTU
1last missing number
212345642
3789101112 
4131415161718 
5192021222324 
6252627282930 
7313233343536 
813738394041 
9252627282930 
10 
11 
1212345638
13789101112 
14131415161718 
15192021222324 
16252627282930 
17313233343536 
18279111315 
19353739404142 
20131415161718 
21 
22 
232345671
24789101112 
25131415161718 
26192021222324 
27252627282930 
28313233343536 
29373839404142 
305711222535 
31589101112 
32101213222324 
33192021222324 
34252627282930 
35313233343536 
Missing
Cell Formulas
RangeFormula
U2:U35U2=IF(AND(T1="",T2<>""),MATCH(0,COUNTIF(O2:INDEX(T:T,ROW()+MATCH(TRUE,T2:T$100="",0)-2),SEQUENCE(999)),0),"")
 
Upvote 0
peter thanks, but is it based on the numbers to be in order? cause if is, my bad, i was trying to give an example which will make sense
sorry

here's another example, more accurate to my data

test
OPQRSTU
1last missing number
23811152838
341214162039
41522262734
52624313637
6101321233041
771718252935
891932334042
92310152042
10148142134
1151729354041
1291113253233
1371223262830
14161924273639
1561822313738
161912153236
1741318193338
182710202634
1951121273042
20142225283941
21368172437
22162329313540
2351418202231
2461016242530
254711192833
261926273641
2731317213738
28152335394042
292812293234
30168192341
31102526283238
3241624313440
3391215172937
342513223035
3571114203642
3631821273339
3781415252733
381318283637
3971319323942
402411262931
4161220243040
4291617213541
4351022233438
test
 
Upvote 0
Try this?
Excel Formula:
=XMATCH(TRUE,ISNA(XMATCH(SEQUENCE(42),TOCOL(O2:T9))),,-1)
 
Upvote 0
Anonymous thanks, but it's aiming of an known range, like o2:t10, then will fill down, o2:t11 and etc and then it wouldn't allways return a the missing number since all 42 may includes inside this range

it's similar and better to what i was about to post, for trying to explain better what i'm after
notice the range in col h is different each time

test
ABCDEFGHIJKLM
1last missing number
23811152838 38
34121416203938
415222627342238
52624313637622313738
6101321233041622313738
77171825293561822313738
89193233404261822313738
923101520423
1014814213438
1151729354041
1291113253233
1371223262830
14161924273639
1561822313738
161912153236
1741318193338
182710202634
1951121273042
20142225283941
21368172437
22162329313540
2351418202231
2461016242530
254711192833
261926273641
2731317213738
test
Cell Formulas
RangeFormula
G2G2=FILTER(SEQUENCE(42),ISNA(XMATCH(SEQUENCE(42),TOCOL(A2:F18))),"")
H2:H3,H9H2=TRANSPOSE(WORKDAY.INTL(0,SEQUENCE(42-1+1-COUNT(LET(t,VSTACK(A3:F13),r,ROWS(t),s,SEQUENCE(r*COLUMNS(t),,0),rs,MOD(s,r)+1,cs,INT(s/r)+1,i,INDEX(t,rs,cs),TRANSPOSE(UNIQUE(SORT(i)))))),"0000000",LET(t,VSTACK(A3:F13),r,ROWS(t),s,SEQUENCE(r*COLUMNS(t),,0),rs,MOD(s,r)+1,cs,INT(s/r)+1,i,INDEX(t,rs,cs),TRANSPOSE(UNIQUE(SORT(i))))))
H4:I4,H10:I10H4=TRANSPOSE(WORKDAY.INTL(0,SEQUENCE(42-1+1-COUNT(LET(t,VSTACK(A5:F14),r,ROWS(t),s,SEQUENCE(r*COLUMNS(t),,0),rs,MOD(s,r)+1,cs,INT(s/r)+1,i,INDEX(t,rs,cs),TRANSPOSE(UNIQUE(SORT(i)))))),"0000000",LET(t,VSTACK(A5:F14),r,ROWS(t),s,SEQUENCE(r*COLUMNS(t),,0),rs,MOD(s,r)+1,cs,INT(s/r)+1,i,INDEX(t,rs,cs),TRANSPOSE(UNIQUE(SORT(i))))))
H5:L5H5=TRANSPOSE(WORKDAY.INTL(0,SEQUENCE(42-1+1-COUNT(LET(t,VSTACK(A6:F14),r,ROWS(t),s,SEQUENCE(r*COLUMNS(t),,0),rs,MOD(s,r)+1,cs,INT(s/r)+1,i,INDEX(t,rs,cs),TRANSPOSE(UNIQUE(SORT(i)))))),"0000000",LET(t,VSTACK(A6:F14),r,ROWS(t),s,SEQUENCE(r*COLUMNS(t),,0),rs,MOD(s,r)+1,cs,INT(s/r)+1,i,INDEX(t,rs,cs),TRANSPOSE(UNIQUE(SORT(i))))))
H6:L6H6=TRANSPOSE(WORKDAY.INTL(0,SEQUENCE(42-1+1-COUNT(LET(t,VSTACK(A7:F14),r,ROWS(t),s,SEQUENCE(r*COLUMNS(t),,0),rs,MOD(s,r)+1,cs,INT(s/r)+1,i,INDEX(t,rs,cs),TRANSPOSE(UNIQUE(SORT(i)))))),"0000000",LET(t,VSTACK(A7:F14),r,ROWS(t),s,SEQUENCE(r*COLUMNS(t),,0),rs,MOD(s,r)+1,cs,INT(s/r)+1,i,INDEX(t,rs,cs),TRANSPOSE(UNIQUE(SORT(i))))))
H7:M7H7=TRANSPOSE(WORKDAY.INTL(0,SEQUENCE(42-1+1-COUNT(LET(t,VSTACK(A8:F14),r,ROWS(t),s,SEQUENCE(r*COLUMNS(t),,0),rs,MOD(s,r)+1,cs,INT(s/r)+1,i,INDEX(t,rs,cs),TRANSPOSE(UNIQUE(SORT(i)))))),"0000000",LET(t,VSTACK(A8:F14),r,ROWS(t),s,SEQUENCE(r*COLUMNS(t),,0),rs,MOD(s,r)+1,cs,INT(s/r)+1,i,INDEX(t,rs,cs),TRANSPOSE(UNIQUE(SORT(i))))))
H8:M8H8=TRANSPOSE(WORKDAY.INTL(0,SEQUENCE(42-1+1-COUNT(LET(t,VSTACK(A9:F14),r,ROWS(t),s,SEQUENCE(r*COLUMNS(t),,0),rs,MOD(s,r)+1,cs,INT(s/r)+1,i,INDEX(t,rs,cs),TRANSPOSE(UNIQUE(SORT(i)))))),"0000000",LET(t,VSTACK(A9:F14),r,ROWS(t),s,SEQUENCE(r*COLUMNS(t),,0),rs,MOD(s,r)+1,cs,INT(s/r)+1,i,INDEX(t,rs,cs),TRANSPOSE(UNIQUE(SORT(i))))))
Dynamic array formulas.
 
Upvote 0
So you don't actually just want the last missing number? Try the following in H2:
Excel Formula:
=FILTER(SEQUENCE(1,42),ISNA(XMATCH(SEQUENCE(1,42),TOCOL(A3:F13))),"")
 
Upvote 0
So you don't actually just want the last missing number? Try the following in H2:
i'm, but sometimes the last row return several missing numbers

Excel Formula:
=FILTER(SEQUENCE(1,42),ISNA(XMATCH(SEQUENCE(1,42),TOCOL(A3:F13))),"")
won't work, again, when fill down, the range stayed fixed, a4:f14, a5:f15 and so on,
and i want the missing number from the row i'm at, say a50, to the closest row after, say a57 or a60... which will return all 41 numbers or close.... and therefor will give me the missing number/s
 
Upvote 0
I can't fathom why you would want this, but try
Excel Formula:
=FILTER(SEQUENCE(1,42),ISNA(XMATCH(SEQUENCE(1,42),TOCOL(TAKE($A3:$F$27,MATCH(41,DROP(REDUCE("",SEQUENCE(ROWS($A3:$F$27)),LAMBDA(x,y,LET(z,ROWS(UNIQUE(TOCOL(TAKE($A3:$F$27,y)))),VSTACK(x,z)))),1),1))))),"")
 
Upvote 0
Solution
Anonymous thanks again, when i change it to another range for checking another data, like that
Excel Formula:
=FILTER(SEQUENCE(1,37),ISNA(XMATCH(SEQUENCE(1,37),TOCOL(TAKE($C3:$H$100,MATCH(36,DROP(REDUCE("",SEQUENCE(ROWS($C3:$H$100)),LAMBDA(x,y,LET(z,ROWS(UNIQUE(TOCOL(TAKE($C3:$H$100,y)))),VSTACK(x,z)))),1),1))))),"")
it gives me only one result when i should have more
did i modify it wrong? the range of numbers are 1 to 37 instead 1 to 42
and the number of rows are about 1500 (only tried 100 for testing)
 
Upvote 0
I don't see anything incorrect with the modified formula, you're going to have to show the data set you are testing it on.

And point out where you are getting the wrong result and what the expected result should be.
 
Upvote 0

Forum statistics

Threads
1,215,106
Messages
6,123,124
Members
449,096
Latest member
provoking

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