I have code below that prompts the user for a date range, and then applies that date range to filter Column A. That information is then copied to another worksheet. How do I keep the user-defined parameters applied to A, clear them from A and apply them to Column O (the letter).
Dim dStartDate As Date
Dim dEndDate As Date
Dim r As Range
dStartDate = CDate(Application.InputBox(Prompt:="Enter Report Start Date (mm/dd/yyyy):", Type:=1))
dEndDate = CDate(Application.InputBox(Prompt:="Enter Report End Date (mm/dd/yyyy):", Type:=1))
On Error Resume Next
Set r = ActiveSheet.AutoFilter.Range
If r Is Nothing Then
ActiveSheet.Range("A1").CurrentRegion.AutoFilter
Set r = ActiveSheet.AutoFilter.Range
End If
ActiveSheet.ShowAllData
On Error GoTo 0
If IsDate(dStartDate) And IsDate(dEndDate) Then
If Application.IsNumber(CLng(dStartDate)) And Application.IsNumber(CLng(dEndDate)) Then
MsgBox dStartDate & " - " & dEndDate
r.AutoFilter Field:=1, _
Criteria1:=">=" & dStartDate, _
Operator:=xlAnd, _
Criteria2:="<=" & dEndDate
End If
End If
Another Question if it's not too much trouble: How do I then copy that new filtered by Column I data directly UNDER the already existing copy/pasted data in the other sheet?
This is all I have so far:
Dim Lastrowdata As Long
Lastrowdata = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Thanks!
Bookmarks