Can we assume your part numbers are integers? Although the part number field is a string, if you have rules in place to ensure it stays an integer, then we might be able to do something.
I tapped AI to solve this one in Excel. First export your list of part numbers (assuming they are integers). Paste them in Excel columnA. In column C put in this formula:
=IFERROR(SMALL(IF(ISNA(MATCH(ROW(INDIRECT(MIN(A:A)&":"&MAX(A:A))), A:A, 0)), ROW(INDIRECT(MIN(A:A)&":"&MAX(A:A))), ""), ROW()-1), "")
Then copy it down column C until you see all the values between the upper and lower limits found in column A. It reports only the unused numbers in the range.
For my own sanity, this is what each part of that wild formula does:
MIN(A:A)
and MAX(A:A)
These get the smallest and largest part numbers in Column A.
Example: If A2:A6 contains 1001, 1002, 1004, 1005
,
then MIN(A:A)
= 1001, and MAX(A:A)
= 1005.
ROW(INDIRECT(MIN(A:A)&":"&MAX(A:A)))
This creates an array of all numbers from the min to max.
Same example: this gives {1001,1002,1003,1004,1005}
.
MATCH(..., A:A, 0)
This tries to match each of those numbers against the values in Column A.
If a number is found, it returns its position; if not, it returns #N/A.
ISNA(MATCH(...))
Wraps the match to check which values are missing from Column A.
Output: {FALSE, FALSE, TRUE, FALSE, FALSE}
— meaning 1003 is missing.
IF(..., ROW(...), "")
This says:
“If the number is missing (ISNA = TRUE), return it.
Otherwise, return blank (”“).”
So, it returns { "", "", 1003, "", "" }
.
SMALL(..., ROW()-1)
This takes the nth smallest non-blank value from that list.
ROW()-1
is used to get 1, 2, 3, etc., as you drag the formula down.
- So the first row gets the 1st missing number, the second gets the 2nd, and so on.
IFERROR(..., "")
Finally, if there are no more missing numbers, it just returns a blank instead of an error.