How to export missing numbers into a separate worksheet

tbeynon1

New Member
Joined
Sep 16, 2015
Messages
15
Here is some code that highlights any missing for any missing numbers in column A.

Code:
'Finding missing report numbers
Dim inc As Integer
Dim inc2 As Integer
Set myrng = Range("A2:A10000")
    myrng.Interior.ColorIndex = xlNone
Set myrng = Range("A3:A10000")
    clr = 3
    inc = Range("A2").Value
    
For Each cel In myrng
        If cel.Value <> (inc + 1) Then
            cel.Interior.ColorIndex = clr
        End If
            inc = cel.Value
    If cel.Value = "" Then
        Exit Sub
    End If
Next

I was wondering if you could change it from highlighting to copying the missing numbers into a new spread sheet.
 
Here is some code that highlights any missing for any missing numbers in column A.

Rich (BB code):
'Finding missing report numbers
Dim inc As Integer
Dim inc2 As Integer
Set myrng = Range("A2:A10000")
    myrng.Interior.ColorIndex = xlNone
Set myrng = Range("A3:A10000")
    clr = 3
    inc = Range("A2").Value
    
For Each cel In myrng
        If cel.Value <> (inc + 1) Then
            cel.Interior.ColorIndex = clr
        End If
            inc = cel.Value
    If cel.Value = "" Then
        Exit Sub
    End If
Next

I was wondering if you could change it from highlighting to copying the missing numbers into a new spread sheet.
Hi tbeynon1,

Assuming you want a list generated on Sheet2 of the current workbook then you could try the following modification to your code:

Rich (BB code):
'Finding missing report numbers
Dim inc As Integer
Dim inc2 As Integer
Dim LastRow As Long

Sheets("Sheet2").Range("A1").Value = "Missing Report Numbers"
LastRow = Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Row + 1


Set myrng = Range("A2:A10000")
    myrng.Interior.ColorIndex = xlNone
Set myrng = Range("A3:A10000")
    clr = 3
    inc = Range("A2").Value
    
For Each cel In myrng
        If cel.Value <> (inc + 1) Then
            Sheets("Sheet2").Range("A" & LastRow).Value = cel.Value
            LastRow = LastRow + 1
        End If
            inc = cel.Value
    If cel.Value = "" Then
        Exit Sub
    End If
Next
 
Upvote 0

Forum statistics

Threads
1,226,876
Messages
6,193,461
Members
453,801
Latest member
777nycole

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