Hi Lynn
It looks as if you need Advanced Filter after you set the range of dates you want to examine.
In the attached workbook, enter the earliest date you want to retrieve in cell G6 on Sheet "Contact Due Dates", and in cell H6 enter the latest date you want to retrieve.
Then click the button Extract Data, and those records will be extracted for you and sorted in ascending order by Lowest Next Contact Date.
The code attached to the button is
Option Explicit
Sub ExtractData()
Dim lr As Long
Dim ws As Worksheet, wsc As Worksheet
Dim myrange As Range
Set ws = Sheets("Contact Due Dates")
Set wsc = Sheets("Client Files")
If Application.Count(ws.Range("G6:H6")) <> 2 Then Exit Sub
Application.ScreenUpdating = False
lr = wsc.Cells(Rows.Count, 1).End(xlUp).Row
wsc.Activate
Set myrange = wsc.Range(Cells(1, 1), Cells(lr, "P"))
ws.Activate
myrange.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=ws.Range( _
"Crit"), CopyToRange:=ws.Range("Destination"), Unique:=False
lr = ws.Cells(Rows.Count, 1).End(xlUp).Row
If lr > 8 Then
ws.Range("A8:H" & lr).Sort Key1:=ws.Range("H8"), Order1:=xlAscending, Header:=xlYes
End If
Application.ScreenUpdating = True
End Sub
You could also simplify your formula in cell M2 of Client files
FROM
=IF(I2="","",IF(J2="","",IF(J2=1,I2+7,IF(J2=2,I2+30,IF(J2=3,I2+90,IF(J2=4,I2+182,IF(J2=5,I2+365,IF(J2=6,"Case Closed",""))))))))
TO
=IF(OR(I2="",J2=""),"",IF(J2=6,"Case Closed",I2+CHOOSE(J2,7,30,90,182,365)))
Bookmarks