Find breaks in a sequence of numbers

elsg

Active Member
Joined
Mar 16, 2013
Messages
295
I would like to run a macro that breaks search following numbers in a selected column, and display
the missing numbers:


Eg


before:


COLUMN A


in 1000
in 1001
in 1002
in 1004
in 1005
in 1006
in 1010
in 1011


then:


COLUMN B


in 1003
in 1007
in 1008
in 1009
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
How about:

Code:
Sub marine()
Dim I As Long, K As Long
K = 1
For I = 2 To Cells(Rows.Count, "A").End(xlUp).Row
    If Cells(I, 1) <> Cells(I - 1, 1) + 1 Then
        Cells(K, 2) = Cells(I, 1) - 1
        K = K + 1
    End If
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,096
Messages
6,053,516
Members
444,669
Latest member
Renarian

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