Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to insert numbers or rows for missing sequential numbers in Excel?

Supposing you have a list of sequential numbers in a worksheet, but there are some missing numbers among the sequence, and now you need to insert the missing numbers or blank rows to make sure the sequence be complete (shown as the following screenshots). How could you quickly solve this problem in Excel?

doc-insert-missing-number1 -2 doc-insert-missing-number2

Insert missing numbers for sequence with Sort and Remove Duplicates feature

Insert missing numbers for sequence with VBA code

Insert blank rows for missing sequence with VBA code

Insert missing numbers or blank rows for sequence with Kutools for Excel


Insert missing numbers or blank rows for missing sequence:

Kutools for Excel’s Find Missing Sequence Number feature can helper you quickly and easily find the missing sequence, and insert the missing numbers or blank rows into the existing data sequence, or fill background color when encountering the missing sequence.

    Insert missing numbers   Insert blank rows
doc-insert-missing-number10 -2 doc-insert-missing-number10 -2 doc-insert-missing-number10

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


arrow blue right bubble Insert missing numbers for sequence with Sort and Remove Duplicates feature


May be you can find the missing numbers one by one, and then insert them, but it is difficult for you to identify the location of the missing ones if there are hundreds of sequential numbers. In Excel, I can use the Sort and Remove Duplicates feature to deal with this task.

1. Following the end of the sequence list, fill in another sequence numbers from 2005023001 to 2005023011. See screenshot:

doc-insert-missing-number3

2. Then select the range of the two sequence numbers and click Data > Sort A to Z, see screenshot:

doc-insert-missing-number4

3. And the selected data has been sorted as following screenshot:

doc-insert-missing-number5

4. Then you need to remove the duplicates by click Data > Remove Duplicates, and in the popped out Remove Duplicates dialog box, check the Column name that you want to remove the duplicates, see screenshots:

doc-insert-missing-number6 -2 doc-insert-missing-number7

5. Then click OK, the duplicates in Column A has been deleted, and the missing numbers in the sequence list have been inserted, see screenshot:

doc-insert-missing-number8


arrow blue right bubble Insert missing numbers for sequence with VBA code

If you feel there are so many steps with the above methods, here also have VBA code can help you finish this problem. Please do as follows:

1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module window.

VBA: insert missing numbers for the sequence

Sub InsertValueBetween()
'Update 20130825
Dim WorkRng As Range
Dim Rng As Range
Dim outArr As Variant
Dim dic As Variant
Set dic = CreateObject("Scripting.Dictionary")
'On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
num1 = WorkRng.Range("A1").Value
num2 = WorkRng.Range("A" & WorkRng.Rows.Count).Value
interval = num2 - num1
ReDim outArr(1 To interval + 1, 1 To 2)
For Each Rng In WorkRng
    dic(Rng.Value) = Rng.Offset(0, 1).Value
Next
For i = 0 To interval
    outArr(i + 1, 1) = i + num1
    If dic.Exists(i + num1) Then
        outArr(i + 1, 2) = dic(i + num1)
    Else
        outArr(i + 1, 2) = ""
    End If
Next
With WorkRng.Range("A1").Resize(UBound(outArr, 1), UBound(outArr, 2))
    .Value = outArr
    .Select
End With
End Sub

3. Then press F5 key to run this code, and a prompt box will pop out, please select the data range that you want to insert the missing numbers(don’t select the title range), see screenshot:

doc-insert-missing-number9

4. And then click OK, the missing numbers have been inserted to the sequence list. See screenshots:

doc-insert-missing-number1 -2 doc-insert-missing-number2

arrow blue right bubble Insert blank rows for missing sequence with VBA code

Sometimes, you just need to locate the place of the missing numbers and insert blank rows between the data, so that you can enter the information as you need. Of course, the following VBA code also can help you solve this problem.

1. Hold down the ALT + F11 keys, and it opens a Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module window.

VBA: insert blank rows for missing sequence

Sub InsertNullBetween()
'Update 20130829
Dim WorkRng As Range
Dim Rng As Range
Dim outArr As Variant
Dim dic As Variant
Set dic = CreateObject("Scripting.Dictionary")
'On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
num1 = WorkRng.Range("A1").Value
num2 = WorkRng.Range("A" & WorkRng.Rows.Count).Value
interval = num2 - num1
ReDim outArr(1 To interval + 1, 1 To 2)
For Each Rng In WorkRng
    dic(Rng.Value) = Rng.Offset(0, 1).Value
Next
For i = 0 To interval
    If dic.Exists(i + num1) Then
        outArr(i + 1, 1) = i + num1
        outArr(i + 1, 2) = dic(i + num1)
    Else
        outArr(i + 1, 1) = ""
        outArr(i + 1, 2) = ""
    End If
Next
With WorkRng.Range("A1").Resize(UBound(outArr, 1), UBound(outArr, 2))
    .Value = outArr
    .Select
End With
End Sub

3. Then press F5 key to run this code, and a prompt box will display, and then select the data range that you want to insert blank rows for the missing sequence(don’t select the title range), see screenshot:

doc-insert-missing-number9

4. And then click OK, the blank rows have been inserted for the missing sequence list. See screenshots:

doc-insert-missing-number1 -2 doc-insert-missing-number10

arrow blue right bubble Insert missing numbers or blank rows for sequence with Kutools for Excel

Here, I will introduce an easy and handy tool- Kutools for Excel, with its Find Missing Sequence Number feature, you can quickly insert the missing sequence number or blank rows between the existing data sequence.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days

If you have installed Kutools for Excel, please do as follows:

1. Select the data sequence that you want to insert the missing numbers.

2. Click Kutools > Insert > Find Missing Sequence Number, see screenshot:

doc-insert-missing-number10

3. In the Find Missing Sequence Number dialog box, check Inserting missing sequence number to insert the missing numbers or Inserting blank rows when encountering missing sequence numbers to insert blank rows as you need. See screenshot:

doc-insert-missing-number10

4. And then click OK button, and the missing sequence numbers or blank rows have been inserted into the data , see screenshots:

doc-insert-missing-number10  2 doc-insert-missing-number10  2 doc-insert-missing-number10

Download and free trial Kutools for Excel Now !


arrow blue right bubble  Demo: Insert missing numbers or blank rows for sequence with Kutools for Excel

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


Related article:

How to identify missing numbers sequence in Excel?


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Manouk · 2 months ago
    I am trying to use the VBA for sequential numbers. I have several columns next to the numbers of which numbers too. I.e.
    1. HL Meter 34
    2. HL Watermeter 40
    4. HL CO2meter 24

    When I use the code it works for the first 3 columns but it gets mixed up if I include the 4th column since it includes numbers too.
    How can I change the code to make sure the numbers in column 4 stay the same?
  • To post as a guest, your comment is unpublished.
    Rob · 2 months ago
    Thank you amazing
  • To post as a guest, your comment is unpublished.
    Gavin Cooke · 2 years ago
    What if i want to select 6 columns and then check 1st column for dates and if dates are missing add a row(blank cells) for all 6 columns
  • To post as a guest, your comment is unpublished.
    phani · 2 years ago
    I want to use "Inserting missing sequence Number" feature
    but it's not supporting for digits more than 12 ?
    there are many sets in which I want to insert the sequence between (it's a alpha-numeric digit)
    can you help
  • To post as a guest, your comment is unpublished.
    phani · 2 years ago
    Hi,
    I want to use "Inserting Missing Sequence Number", but it's not supporting if the no. of digits are more than 12
    can you help ?