+ Reply to Thread
Results 1 to 8 of 8

Advanced Filter to Dynamic Range

  1. #1
    John
    Guest

    Advanced Filter to Dynamic Range

    I've applied an Advanced Filter to a Range and simply recorded the macro,
    extract below, but my problem is that my data in the Database sheet is
    dynamic and changes in Row length (not by column)

    How can I incorporate a dynamic range via VBA with Advanced Filters?

    Thanks



    Sheets("Database").Select
    Range("A1:T61").AdvancedFilter Action:=xlFilterCopy,
    CriteriaRange:=Range( _
    "V1:V2"), CopyToRange:=Range("X1:AQ1"), Unique:=False
    Range("A1").Select



  2. #2
    Tom Ogilvy
    Guest

    Re: Advanced Filter to Dynamic Range

    Sheets("Database").Select
    Range("A1").CurrentRegion.AdvancedFilter _
    Action:=xlFilterCopy,
    CriteriaRange:=Range("V1:V2"), _
    CopyToRange:=Range("X1:AQ1"), Unique:=False
    Range("A1").Select

    --
    Regards,
    Tom Ogilvy



    "John" <r.@9999yahoo.co.uk> wrote in message
    news:dl57c9$i30$1@reader01.news.esat.net...
    > I've applied an Advanced Filter to a Range and simply recorded the macro,
    > extract below, but my problem is that my data in the Database sheet is
    > dynamic and changes in Row length (not by column)
    >
    > How can I incorporate a dynamic range via VBA with Advanced Filters?
    >
    > Thanks
    >
    >
    >
    > Sheets("Database").Select
    > Range("A1:T61").AdvancedFilter Action:=xlFilterCopy,
    > CriteriaRange:=Range( _
    > "V1:V2"), CopyToRange:=Range("X1:AQ1"), Unique:=False
    > Range("A1").Select
    >
    >




  3. #3
    Nigel
    Guest

    Re: Advanced Filter to Dynamic Range

    Dim LastRow as Long
    LastRow = Sheets("Database").Cells(Rows.Count,1).End(xlup).Row


    With Sheets("Database").Select
    Range("A1:T" & LastRow).AdvancedFilter Action:=xlFilterCopy,

    CriteriaRange:=Range( _
    "V1:V2"), CopyToRange:=Range("X1:AQ1"), Unique:=False
    Range("A1").Select

    --
    Cheers
    Nigel



    "John" <r.@9999yahoo.co.uk> wrote in message
    news:dl57c9$i30$1@reader01.news.esat.net...
    > I've applied an Advanced Filter to a Range and simply recorded the macro,
    > extract below, but my problem is that my data in the Database sheet is
    > dynamic and changes in Row length (not by column)
    >
    > How can I incorporate a dynamic range via VBA with Advanced Filters?
    >
    > Thanks
    >
    >
    >
    > Sheets("Database").Select
    > Range("A1:T61").AdvancedFilter Action:=xlFilterCopy,
    > CriteriaRange:=Range( _
    > "V1:V2"), CopyToRange:=Range("X1:AQ1"), Unique:=False
    > Range("A1").Select
    >
    >




  4. #4
    John
    Guest

    Re: Advanced Filter to Dynamic Range

    Thanks Guys

    "Nigel" <nigel-sw@suxnospampanet.com> wrote in message
    news:e1uErv65FHA.2628@TK2MSFTNGP11.phx.gbl...
    > Dim LastRow as Long
    > LastRow = Sheets("Database").Cells(Rows.Count,1).End(xlup).Row
    >
    >
    > With Sheets("Database").Select
    > Range("A1:T" & LastRow).AdvancedFilter Action:=xlFilterCopy,
    >
    > CriteriaRange:=Range( _
    > "V1:V2"), CopyToRange:=Range("X1:AQ1"), Unique:=False
    > Range("A1").Select
    >
    > --
    > Cheers
    > Nigel
    >
    >
    >
    > "John" <r.@9999yahoo.co.uk> wrote in message
    > news:dl57c9$i30$1@reader01.news.esat.net...
    >> I've applied an Advanced Filter to a Range and simply recorded the macro,
    >> extract below, but my problem is that my data in the Database sheet is
    >> dynamic and changes in Row length (not by column)
    >>
    >> How can I incorporate a dynamic range via VBA with Advanced Filters?
    >>
    >> Thanks
    >>
    >>
    >>
    >> Sheets("Database").Select
    >> Range("A1:T61").AdvancedFilter Action:=xlFilterCopy,
    >> CriteriaRange:=Range( _
    >> "V1:V2"), CopyToRange:=Range("X1:AQ1"), Unique:=False
    >> Range("A1").Select
    >>
    >>

    >
    >




  5. #5
    John
    Guest

    Re: Advanced Filter to Dynamic Range

    Guys I'm getting a syntax error on both your codes, am I missing something?
    Where does the 'CurrentRegion' come from?


    "Nigel" <nigel-sw@suxnospampanet.com> wrote in message
    news:e1uErv65FHA.2628@TK2MSFTNGP11.phx.gbl...
    > Dim LastRow as Long
    > LastRow = Sheets("Database").Cells(Rows.Count,1).End(xlup).Row
    >
    >
    > With Sheets("Database").Select
    > Range("A1:T" & LastRow).AdvancedFilter Action:=xlFilterCopy,
    >
    > CriteriaRange:=Range( _
    > "V1:V2"), CopyToRange:=Range("X1:AQ1"), Unique:=False
    > Range("A1").Select
    >
    > --
    > Cheers
    > Nigel
    >
    >
    >
    > "John" <r.@9999yahoo.co.uk> wrote in message
    > news:dl57c9$i30$1@reader01.news.esat.net...
    >> I've applied an Advanced Filter to a Range and simply recorded the macro,
    >> extract below, but my problem is that my data in the Database sheet is
    >> dynamic and changes in Row length (not by column)
    >>
    >> How can I incorporate a dynamic range via VBA with Advanced Filters?
    >>
    >> Thanks
    >>
    >>
    >>
    >> Sheets("Database").Select
    >> Range("A1:T61").AdvancedFilter Action:=xlFilterCopy,
    >> CriteriaRange:=Range( _
    >> "V1:V2"), CopyToRange:=Range("X1:AQ1"), Unique:=False
    >> Range("A1").Select
    >>
    >>

    >
    >




  6. #6
    John
    Guest

    Re: Advanced Filter to Dynamic Range

    Guys got it working, must have paste it incorrectly

    Thanks


    "John" <r.@9999yahoo.co.uk> wrote in message
    news:dl5htj$li2$1@reader01.news.esat.net...
    > Guys I'm getting a syntax error on both your codes, am I missing
    > something? Where does the 'CurrentRegion' come from?
    >
    >
    > "Nigel" <nigel-sw@suxnospampanet.com> wrote in message
    > news:e1uErv65FHA.2628@TK2MSFTNGP11.phx.gbl...
    >> Dim LastRow as Long
    >> LastRow = Sheets("Database").Cells(Rows.Count,1).End(xlup).Row
    >>
    >>
    >> With Sheets("Database").Select
    >> Range("A1:T" & LastRow).AdvancedFilter Action:=xlFilterCopy,
    >>
    >> CriteriaRange:=Range( _
    >> "V1:V2"), CopyToRange:=Range("X1:AQ1"), Unique:=False
    >> Range("A1").Select
    >>
    >> --
    >> Cheers
    >> Nigel
    >>
    >>
    >>
    >> "John" <r.@9999yahoo.co.uk> wrote in message
    >> news:dl57c9$i30$1@reader01.news.esat.net...
    >>> I've applied an Advanced Filter to a Range and simply recorded the
    >>> macro,
    >>> extract below, but my problem is that my data in the Database sheet is
    >>> dynamic and changes in Row length (not by column)
    >>>
    >>> How can I incorporate a dynamic range via VBA with Advanced Filters?
    >>>
    >>> Thanks
    >>>
    >>>
    >>>
    >>> Sheets("Database").Select
    >>> Range("A1:T61").AdvancedFilter Action:=xlFilterCopy,
    >>> CriteriaRange:=Range( _
    >>> "V1:V2"), CopyToRange:=Range("X1:AQ1"), Unique:=False
    >>> Range("A1").Select
    >>>
    >>>

    >>
    >>

    >
    >




  7. #7
    Registered User
    Join Date
    06-12-2019
    Location
    Piracicaba, SP - Brazil
    MS-Off Ver
    16 pro plus
    Posts
    1

    Re: Advanced Filter to Dynamic Range

    I didn't understand the criteria. Why V1:V2??

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Advanced Filter to Dynamic Range

    Quote Originally Posted by Glim4 View Post
    I didn't understand the criteria. Why V1:V2??
    This thread is almost 15 years old. I doubt anyone is still following it. Plus please start your own thread with your question - refer to this thread if you think it is relevant.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ Reply to Thread

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