List Missing Number in Large Sequence

drockdamian

New Member
Joined
Dec 13, 2021
Messages
11
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello All,

I have a sequence of invoice numbers that I need to find AND list the missing invoice numbers. The beginning invoice number is 97680 and the last one is 198698. The difference between these two numbers is 101,018, however, a count of the range is 99062 (missing 1,956 invoice numbers in the sequence). I have searched the internet and keep seeing this formula:

=IFERROR(SMALL(IF(COUNTIF($A$1:$A$135,
MIN($A$1:$A$135)+ROW($1:$135)-1)=0,
MIN($A$1:$A$135)+ROW($1:$135)-1),ROW(A1)),"")

So it works for this limited range but when I try to expand the range to $A$1:$A$99062 to cover my range it does not work. Any ideas here would be helpful!
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Try this.
You have to press "Ctrl+Shift+Enter" instead of "Enter" only.
Excel Formula:
=IFERROR(SMALL(IF(COUNTIF($A$1:$A$99062,
MIN($A$1:$A$99062 )+ROW($1:$99062 )-1)=0,
MIN($A$1:$A$99062 )+ROW($1:$99062 )-1),ROW(A1)),"")
The code is beautiful and awesome.
 
Upvote 0
Which version of excel are you using?

This comes to mind as something that might work but I haven't been able to test it.

Excel Formula:
=LET(s,SEQUENCE(101018,97680),FILTER(s,MATCH(s,A:A)<s))
 
Upvote 0
Try this.
You have to press "Ctrl+Shift+Enter" instead of "Enter" only.
Excel Formula:
=IFERROR(SMALL(IF(COUNTIF($A$1:$A$99062,
MIN($A$1:$A$99062 )+ROW($1:$99062 )-1)=0,
MIN($A$1:$A$99062 )+ROW($1:$99062 )-1),ROW(A1)),"")
The code is beautiful and awesome.
Hi HongRu, I have tried the ctrl shift enter but it still returns a zero. However when I leave the formula as I found up to range A1:135 it works. I can’t figure out what I am doing wrong so that it does not work once I expand the range.
 
Upvote 0
Which version of excel are you using?

This comes to mind as something that might work but I haven't been able to test it.

Excel Formula:
=LET(s,SEQUENCE(101018,97680),FILTER(s,MATCH(s,A:A)<s))
Thanks Jasonb75. I am using Excel 2019. I will have to try this!
 
Upvote 0
With 2019 you will not have some of the functions that I have used.

I'll have a look at an alternative for you shortly when I have my laptop to test it on.
 
Upvote 0
Trying a couple of things in excel, I'm wondering if it might be too much to process with the original formula and the full range of numbers, I've been noticing some delay when I tried anything using countifs.

This works for me in office 365 using methods that are compatible with older versions of excel. Hopefully it will work for you as well.

Firstly, you need to create a named range (it can be done without but this improves performance with a larger range of numbers).

Go to the Formulas tab on the excel ribbon, then click Name Manager, followed by New and enter the following into the boxes.
You will need to change the sheet name to match yours, and the references to the data column if different.

Name: rowarray
Scope: Workbook
Refers to: =ROW(Sheet1!$A$1:INDEX(Sheet1!$A:$A,MAX(Sheet1!$A:$A)))

Then enter this formula into your sheet and array confirm it with Ctrl Shift Enter before filling down as needed.

Excel Formula:
=IFERROR(AGGREGATE(15,6,rowarray/(LOOKUP(N(IF({1},rowarray)),A:A)<>rowarray),ROWS(A$1:A1)),"")
 
Upvote 0
How about
Fluff.xlsm
ABC
1976809770297680
297681397689
39768297697
49768397699
597684 
697685 
797686 
897687 
997688 
1097690 
1197691 
1297692 
1397693 
1497694 
1597695 
1697696 
1797698 
1897700 
1997701 
2097702 
21
Main
Cell Formulas
RangeFormula
B1B1=MAX(A1:A99100)
B2B2=NETWORKDAYS.INTL(C1,B1,"0000000",A1:A99100)
C1C1=MIN(A1:A99100)
C2:C20C2=IF(ROWS(C$2:C2)>$B$2,"",WORKDAY.INTL(C1,1,"0000000",$A$2:$A$99063))
 
Upvote 0
Trying a couple of things in excel, I'm wondering if it might be too much to process with the original formula and the full range of numbers, I've been noticing some delay when I tried anything using countifs.

This works for me in office 365 using methods that are compatible with older versions of excel. Hopefully it will work for you as well.

Firstly, you need to create a named range (it can be done without but this improves performance with a larger range of numbers).

Go to the Formulas tab on the excel ribbon, then click Name Manager, followed by New and enter the following into the boxes.
You will need to change the sheet name to match yours, and the references to the data column if different.

Name: rowarray
Scope: Workbook
Refers to: =ROW(Sheet1!$A$1:INDEX(Sheet1!$A:$A,MAX(Sheet1!$A:$A)))

Then enter this formula into your sheet and array confirm it with Ctrl Shift Enter before filling down as needed.

Excel Formula:
=IFERROR(AGGREGATE(15,6,rowarray/(LOOKUP(N(IF({1},rowarray)),A:A)<>rowarray),ROWS(A$1:A1)),"")
Thank you so much! This worked perfectly.
 
Upvote 0
How about
Fluff.xlsm
ABC
1976809770297680
297681397689
39768297697
49768397699
597684 
697685 
797686 
897687 
997688 
1097690 
1197691 
1297692 
1397693 
1497694 
1597695 
1697696 
1797698 
1897700 
1997701 
2097702 
21
Main
Cell Formulas
RangeFormula
B1B1=MAX(A1:A99100)
B2B2=NETWORKDAYS.INTL(C1,B1,"0000000",A1:A99100)
C1C1=MIN(A1:A99100)
C2:C20C2=IF(ROWS(C$2:C2)>$B$2,"",WORKDAY.INTL(C1,1,"0000000",$A$2:$A$99063))
Thank you so much! This worked too.
 
Upvote 0

Forum statistics

Threads
1,215,026
Messages
6,122,738
Members
449,094
Latest member
dsharae57

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