Auditing sequential datasets for gaps-such as missing invoice or check numbers-is a notoriously tedious task for financial analysts. When reconciliation involves tracking disbursements from standard funding sources like federal grants or private foundations, manual reviews often lead to costly oversight. Utilizing a dynamic Excel formula solves this, as it grants immediate visibility into numerical discrepancies. Under the stipulation that your sequence is sorted, this logical approach reliably highlights omissions, a method proven highly effective when auditing check sequences for major donor campaigns. Below, we outline the exact formula configurations and logic to streamline your sequential audits.
Managing large datasets in Microsoft Excel often involves working with sequential numeric identifiers, such as invoice numbers, purchase orders, check numbers, or employee IDs. When analyzing these lists, one of the most common auditing tasks is identifying gaps or missing numbers in the sequence. A missing number could indicate a skipped invoice, a lost transaction record, or a data entry error.
Depending on your version of Excel and your specific dataset, there are several ways to find these missing sequential numbers. This comprehensive guide covers five powerful methods: from simple helper columns and conditional formatting to advanced dynamic array formulas, Power Query, and VBA.
If you are using a modern version of Excel (Excel 365 or Excel 2021), you have access to dynamic arrays. These allow you to generate a list of missing numbers instantly in a single cell, without needing helper columns or sorting your original data first.
The logic behind this approach is simple: we generate a complete, perfect sequence of numbers starting from your minimum value to your maximum value. Then, we filter that sequence to return only the numbers that do not appear in your actual list.
Assuming your list of sequential numbers is in the range A2:A20, enter the following formula in an empty cell:
=LET(
actual_list, A2:A20,
min_val, MIN(actual_list),
max_val, MAX(actual_list),
full_sequence, SEQUENCE(max_val - min_val + 1, 1, min_val),
FILTER(full_sequence, ISNA(MATCH(full_sequence, actual_list, 0)), "No missing numbers")
)
SEQUENCE function generates a continuous list of numbers from the minimum to the maximum value. For example, if your minimum is 1001 and your maximum is 1010, it generates {1001; 1002; 1003; ...; 1010}.MATCH function attempts to find each number of the full_sequence in your actual_list. If a number is missing, MATCH returns an #N/A error. ISNA converts these errors to TRUE.FILTER function extracts only the numbers from the full_sequence where the ISNA result is TRUE. If no numbers are missing, it returns the text "No missing numbers".If you are using Excel 2019, 2016, or older, you do not have access to dynamic array functions like SEQUENCE or FILTER. Instead, you can use a simple helper column. This method requires your sequence to be sorted in ascending order.
=IF(A3 - A2 > 1, "Gap after " & A2, "")
The formula checks if the difference between the current number (A3) and the previous number (A2) is greater than 1. If it is, that means one or more numbers are missing between them. The formula flag alerts you by displaying "Gap after" followed by the last known correct number in the sequence.
To list the exact missing numbers instead of just flagging the gap, you can expand this logic using a secondary sequential list in another column and running a VLOOKUP or MATCH to find missing elements.
Sometimes you don't need to extract the missing numbers into a separate list; you simply want to visually identify where the sequence breaks. Excel's Conditional Formatting feature is perfect for this.
=AND(A2<>"", A3-A2>1)
Now, Excel will automatically highlight any cell where the sequence jumps by more than 1, showing you exactly where a gap begins.
If you work with large datasets that refresh regularly, Power Query is the most robust tool to find missing numbers. It is built into Excel (under the Data tab as Get & Transform Data) and does not require complex formulas.
InvoiceNumber).#"Changed Type" and column names to match your steps):
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"InvoiceNumber", Int64.Type}}),
// Find the minimum and maximum values in your list
MinVal = List.Min(#"Changed Type"[InvoiceNumber]),
MaxVal = List.Max(#"Changed Type"[InvoiceNumber]),
// Generate a complete sequential list of numbers
FullSequence = {MinVal..MaxVal},
// Convert the list to a table
TableFromList = Table.FromList(FullSequence, Splitter.SplitByNothing(), {"FullSequence"}, null, ExtraValues.Error),
#"Changed Type1" = Table.TransformColumnTypes(TableFromList,{{"FullSequence", Int64.Type}}),
// Merge queries to find missing values (Left Anti Join)
MergedQueries = Table.NestedJoin(#"Changed Type1", {"FullSequence"}, #"Changed Type", {"InvoiceNumber"}, "OriginalTable", JoinKind.LeftAnti),
#"Removed Columns" = Table.RemoveColumns(MergedQueries,{"OriginalTable"})
in
#"Removed Columns"
Why this is powerful: Whenever your original data updates, you simply go to the Data tab and click Refresh All. Power Query will automatically recalculate and update your list of missing numbers.
For users who prefer a legacy one-click automation tool, a VBA macro can scan any selected range, calculate the missing numbers, and output them in a new column.
Press ALT + F11 to open the VBA Editor, insert a new Module (Insert > Module), and paste the following code:
Sub FindMissingNumbers()
Dim rng As Range
Dim cell As Range
Dim dict As Object
Dim minVal As Long, maxVal As Long
Dim i As Long, outputRow As Long
' Ask user to select the range
On Error Resume Next
Set rng = Application.InputBox("Select your range of numbers:", Type:=8)
On Error GoTo 0
If rng Is Nothing Then Exit Sub
' Initialize Dictionary
Set dict = CreateObject("Scripting.Dictionary")
' Find Min and Max, and load values to dictionary
minVal = Application.WorksheetFunction.Min(rng)
maxVal = Application.WorksheetFunction.Max(rng)
For Each cell In rng
If IsNumeric(cell.Value) And cell.Value <> "" Then
dict(cell.Value) = True
End If
Next cell
' Ask user where to write the results
Dim targetCell As Range
On Error Resume Next
Set targetCell = Application.InputBox("Select starting cell for output:", Type:=8)
On Error GoTo 0
If targetCell Is Nothing Then Exit Sub
outputRow = 0
' Loop through sequence and find missing numbers
Application.ScreenUpdating = False
For i = minVal To maxVal
If Not dict.Exists(i) Then
targetCell.Offset(outputRow, 0).Value = i
outputRow = outputRow + 1
End If
Next i
Application.ScreenUpdating = True
If outputRow = 0 Then
MsgBox "No missing numbers found!", vbInformation
Else
MsgBox outputRow & " missing numbers found and listed.", vbInformation
End If
End Sub
To run this macro, press ALT + F8, select FindMissingNumbers, and click Run. The script will ask you to select the range containing your original list, and then ask you to select where you want the missing numbers written.
| Method | Excel Version Needed | Pros | Cons |
|---|---|---|---|
| Dynamic Array (LET/FILTER) | Office 365 / Excel 2021 | Extremely fast, automated, no macros or sorting required. | Not compatible with older Excel versions. |
| Helper Column Formula | Any Excel Version | Simple to set up, works in all legacy files. | Requires sorting your data first; only flags where gaps start. |
| Conditional Formatting | Any Excel Version | Visualizes gaps directly inside your existing table. | Does not create a clean list of missing items. |
| Power Query | Excel 2010 or newer | Excellent for large datasets, automated refreshes. | Slightly steeper learning curve. |
| VBA Macro | Excel (Desktop only) | One-click solution, works on any workbook. | Requires macro-enabled workbook formats (.xlsm). |
Choosing the right method depends entirely on your workflow. If you are on the latest Office suite, the Dynamic Array (Method 1) formula is the most elegant solution. For ongoing automated data preparation pipelines, Power Query (Method 4) is highly recommended.
Disclaimer:
The documents and templates provided on this page are for informational and illustrative purposes only. They do not constitute professional, legal, or financial advice, and should not be relied upon as such. Because individual circumstances and regulatory requirements vary, these materials may not be suitable for your specific needs. We recommend consulting with a qualified professional before adapting or using any of these examples for official or commercial purposes.