Option Explicit
Sub exa2()
Dim _
DIC As Object, _
wksData As Worksheet, _
rngReport As Range, _
Val As Variant, _
aryUniqRept As Variant, _
aryData As Variant, _
ary_lData As Variant, _
ary_lDataCol2 As Variant, _
DicItems As Variant, _
x As Long, _
y As Long, _
i As Long
'// CHange sheetname to suit //
Set wksData = ThisWorkbook.Worksheets(ActiveSheet.Name)
Set rngReport = Range(wksData.Range("B2"), wksData.Cells(Rows.Count, "B").End(xlUp))
Set DIC = CreateObject("Scripting.Dictionary")
With DIC
For Each Val In rngReport
.Item(Val) = Val
Next
aryUniqRept = Application.Transpose(.Items)
.RemoveAll
End With
With rngReport
aryData = .Resize(, 2).Value
ReDim ary_lData(1 To UBound(aryData, 1), 1 To 2)
For x = 1 To UBound(ary_lData, 1)
ary_lData(x, 1) = aryData(x, 1)
'// Must be a better way, but I thought to append each report with the //
'// coresponding date's long //
ary_lData(x, 2) = aryData(x, 1) & CLng(aryData(x, 2))
Next
ary_lDataCol2 = Application.Index(ary_lData, , 2)
For i = 1 To UBound(aryUniqRept, 1)
For x = 1 To UBound(ary_lData, 1)
If aryUniqRept(i, 1) = ary_lData(x, 1) Then
'// If we find a day after or before a given report, add the //
'// report to a collection and jump to next report //
If Not IsError(Application.Match(CStr(ary_lData(x, 2) + 1), _
ary_lDataCol2, 0)) _
Or Not IsError(Application.Match(CStr(ary_lData(x, 2) - 1), _
ary_lDataCol2, 0)) Then
DIC.Item(ary_lData(x, 1)) = ary_lData(x, 1)
Exit For
End If
End If
Next
Next
ReDim aryData(1 To DIC.Count, 1 To 1) As Long
DicItems = DIC.Items
For i = 1 To DIC.Count
aryData(i, 1) = DicItems(i - 1)
Next
End With
'// To list the reports that took two or more consecutive days //
wksData.Range("G2").Resize(UBound(aryData, 1)).Value = aryData
'// To list how many reports //
wksData.Range("H2").Value = DIC.Count
End Sub
Does that help?