Forum Discussion
Kasafkhan
Aug 06, 2022Copper Contributor
Find missing dates
Good day to all members, I am struggling with dates. I attached a file for example. I need to find the missing dates between the dates & report them, Anyone can please suggest me a way to do it?
OliverScheurich
Aug 06, 2022Gold Contributor
Sub missingdates()
Dim i As Long
Dim k As Long
Dim m As Long
Dim n As Long
Dim p As Long
Dim maxrow As Long
maxrow = Range("A" & Rows.Count).End(xlUp).Row
Range("C:C").Clear
n = 1
p = 1
For i = 1 To maxrow
If Cells(i, 1).Value + 1 <> Cells(i + 1, 1) And Cells(i + 1, 1) <> "" Then
k = Cells(i + 1, 1).Value - Cells(i, 1).Value
If k = 2 Then
Cells(n, 3).Value = Cells(i, 1).Value + 1
n = n + 1
Else
For m = 1 To k - 1
Cells(n, 3).Value = Cells(i, 1).Value + p
p = p + 1
n = n + 1
Next m
p = 1
End If
Else
End If
Next i
End Sub
Maybe with this code. After sorting the dates in column A in ascending order you can click the button in cell F3 in the attached file to run the macro.