## Identify missing values in a column using excel formula

**Table of contents**

### Missing numbers (array formula)

**Question:** I want to find missing numbers in a range?

**Answer: **C1 and C2 contain the range boundaries.

**Array Formula in B5**

**How to create an array formula**

- Select cell B5
- Copy / Paste array formula
- Press and hold Ctrl + Shift
- Press Enter
- Release all keys

**How to copy array formula**

- Copy cell B5
- Select cell B6:B11
- Paste

**Download excel sample file for this tutorial.**

missing-values-in-a-column.xlsx

(Excel 2007 Workbook *.xlsx)

### Functions in this article:

**MATCH(**lookup_value;lookup_array; [match_type]

Returns the relative position of an item in an array that matches a specified value

**INDEX(**array,row_num,[column_num]**)**

Returns a value or reference of the cell at the intersection of a particular row and column, in a given range

**IF(**logical_test;[value_if:true];[value_if_false]**)
**Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE

**ROW(**reference**)**

returns the rownumber of a reference

**SMALL(**array,k**)**

Returns the k-th smallest row number in this data set.

**OFFSET(**reference,rows,columns,[height],[width]**)
**Returns a reference to a range that is a given number of rows and columns from a given reference.

### Missing numbers (vba)

The macro demonstrated here let´s you select a cell range (values must be in a single column), start and end number.

A new sheet is created, values are sorted in the first column. The second column (B) contains all missing values.

### VBA

Sub Missingvalues() Dim rng As Range Dim rng1 As Range Dim StartV As Double, EndV As Double, i As Double, j As Single Dim k() As Double Dim WS As Worksheet ReDim k(0) On Error Resume Next Set rng = Application.InputBox(Prompt:="Select a range:", _ Title:="Extract missing values", _ Default:=Selection.Address, Type:=8) StartV = InputBox("Start value:") EndV = InputBox("End value:") On Error GoTo 0 Set WS = Sheets.Add WS.Range("A1:A" & rng.Rows.CountLarge).Value = rng.Value With WS.Sort .SortFields.Add Key:=WS.Range("A1"), _ SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal .SetRange Range("A1:A" & rng.Rows.CountLarge) .Header = xlNo .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With MsgBox "test" Set rng1 = WS.Range("A1:A" & rng.Rows.CountLarge) For i = StartV To EndV On Error Resume Next j = Application.Match(i, rng1) If Err = 0 Then If rng1(j, 1) <> i Then k(UBound(k)) = i ReDim Preserve k(UBound(k) + 1) End If Else k(UBound(k)) = i ReDim Preserve k(UBound(k) + 1) End If On Error GoTo 0 Application.StatusBar = i Next i WS.Range("B1") = "Missing values" WS.Range("B2:B" & UBound(k) + 1) = Application.Transpose(k) End Sub

### Download *.xlsm file

### 24 Responses to “Identify missing values in a column using excel formula”

### Leave a Reply

**How to add a formula to your comment:**

<code>your formula</code>

**How to add VBA code to your comment:**

[vb 1="vbnet" language=","]

VBA code

[/vb]

**How to add a picture to your comment:**

Upload picture to postimage.org

Add picture link to comment.

**Contact Oscar**

You can contact me through this webpage

hi,

how can we extend the same to 8000 rows in a column,

creating array formula as you said is not working

Select cell B5

Copy / Paste array formula

Press and hold Ctrl + Shift

Press Enter

Release all keys

what should i do to continue ,

any alternative method to copy the array formula

expecting a reply at the earliest

anchal j vattakunnel,

Adjust cell range (bolded)

=SMALL(IF(ISERROR(MATCH($C$1+ROW(OFFSET($A$1, 0, 0, $C$2-$C$1+1))-1,

$A$2:$A$6, 0)), $C$1+ROW(OFFSET($A$1, 0, 0, $C$2-$C$1+1))-1), ROW(A1))Just wanted to say thanks. This worked on a huge range of data that I had. Really appreciate it!

hi

i have 65000 nos in a column how can in find the missing nos. the above formula cannot work.... please help me to rectify the problem. very urgent...

I couldn't get the formula to work either, by changing the range. Could you please help me also with out using VBA?

Thanks

Kenneth G,

How large is your range?

1-3660

The formula should work. Can you provide your formula? Did you create an array formula?

was not hitting ctrl+shift+enter. it works now!

Dear All,

I have serial numbers from 1 to 40,000 entry in excel. In-between serial numbers there some missing numbers. How can I findout what are the missing numbers from large serial numbers i.e. 1 to 40,000.

For e.g. there are serial numbers 1, 2, 4, 5, 6, 8, 9, 10 like wise i have 60,000numbers. Here missing numbers are 3, 7. How I will findout missing numbers 3 & 7 easily.

Kindly help me.

With advance thanks.

Regards,

Nihar

XLRI

abu and ravi,

I have added a vba solution to this post: Missing numbers (vba)

I want to find missing numbers starting from 80000001 to 80003200, how to find it by VBA code, Excel gets hang after entering VBA code.

Chetan Sonawane,

Yes, you are right. Try the new file Find-missing-values-version2.xlsm. Link above.

I want to split one single coloum of approximately 12000 values into several coloums so that I can take print of such numbers on pages, plz help me on this. how to do it ?

Chetan Sonawane,

Adjust cell range Sheet1!$A$1:$A$151.

Download excel *.xlsx file

Rearrange-data-from-a-column-to-multiple-columns.xlsx

Thank you Oscar very much, due to your help my work is getting easy. I tried spliting 12935 values in Excel using MS Office 2007, but the file works very slowly , Shall I install MS Office 2010 ?, will it work more faster ? I want your Advice.

I want to find missing value staring with alphabets like B00001 to B11221, how to find it by VBA code, please post new code.

Dear sir,

I wish to find missing nos. starting with alphabets like S0001 to S1122, Please send the code.

How to find missing nos which starts with B0001 or S-001

Dear Osacar Sir,

Please send me solution for finding missing nos starting with J000001 or S000001

Chetan Sonawane,

Create a new column and remove J and S from your lists.

If your list is in column A, cell B1:

=RIGHT(A1,LEN(A1)-1)*1

Copy formula downwards as far as needed.

Start macro and use it on column B.

Dear Sir,

Instead of formula can you help me with VBA code, If you can please modify VBA code for finding missing nos starting with J000001 or S000001

How i can put values of missing sequential numbers?

Number values

1 30

4 20

missing number 2 having value 10

missing number 3 having value 50

Hi Oscar,

I have tried the Array Formula, however, when i hit CTRL+Shift+Enter nothing happens. All the fields are highlighted but it does not provide any info. Any ideas?

Please help