Finding missing dates

sassiisarah

New Member
Joined
Sep 18, 2017
Messages
1
Hi,

I have a very large date sequence in which dates repeat themselves multiple times (e.g 5/31, 5/31, 5/31, 6/1, 6/1, 6/2, etc). But some dates are missing in this type of date list and I am not sure how to find the missing dates, as I have about 400,000 rows of these dates in this format. Can someone please help me find a way to do this? Thank you!!
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
This should work. Note the 2 caveats within the code.
Code:
Sub MissingDate()
Dim X, Y, Fnd, cnt as long
Dim MissingDates(100000, 1) As Date
Dim TheDate As Date
'Place cursor at first date in list before executing this macro.  Dates MUST BE sorted before executing this macro.
Let X = ActiveCell.Row
Let Y = ActiveCell.Column
Let TheDate = Cells(X, Y).Value
Do While True
    X = X + 1
    If Cells(X, Y).Value = TheDate Then
        'date is same as previous do nothing
    ElseIf Cells(X, Y).Value = Empty Then
        'last date, exit while
        Exit Do
    Else
        'Different date
        Let cnt = 0
        Do While True
            Let cnt = cnt + 1
            If TheDate + cnt = Cells(X, Y).Value Then
                Let TheDate = Cells(X, Y).Value
                Exit Do
            Else
                Fnd = Fnd + 1
                Let MissingDates(Fnd, 1) = TheDate + cnt
            End If
        Loop
    End If
Loop

Workbooks.Add Template:="Workbook"
MyTemp = ActiveWorkbook.Name
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "Missing Dates"
Cells(1, 1).Value = "Missing Dates"
For X = 1 To Fnd
    Cells(X + 1, 1).Value = MissingDates(X, 1)
Next
Columns("A:A").EntireColumn.AutoFit
Range("A2").Select
ActiveWindow.FreezePanes = True
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,248
Messages
6,123,867
Members
449,130
Latest member
lolasmith

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