Aug 06 2022 05:26 AM
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?
Aug 06 2022 06:17 AM
Aug 06 2022 06:22 AM
It depends on which Excel version/platform you are. If with supporting dynamic arrays that could be
=LET(
minDate, MIN( dates ),
maxDate, MAX( dates),
allDates, SEQUENCE( maxDate - minDate + 1, , minDate ),
FILTER( allDates, ISNA(XLOOKUP( allDates, dates, dates)))
)
Aug 06 2022 06:31 AM
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.