Results 1 to 2 of 2

How do I transfer User-Defined filter parameters to then filter another column?

Threaded View

  1. #1
    Registered User
    Join Date
    02-28-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    2

    How do I transfer User-Defined filter parameters to then filter another column?

    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!
    Last edited by fiqulupo; 02-28-2012 at 07:05 PM. Reason: Solved it

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1