Consulting

Results 1 to 6 of 6

Thread: Solved: Relative range for advanced filter

  1. #1

    Question Solved: Relative range for advanced filter

    I am trying to use advanced filter function for a relative range that will change everyday.
    does anyone know how to do it?
    Thanks,

    Yasar

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    how does it change every day? Can you use a named range, it will not chnage if rows are deleted etc.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    Quote Originally Posted by lucas
    how does it change every day? Can you use a named range, it will not chnage if rows are deleted etc.
    there will be new rows added to it,
    Here is the code I am using

    Range("G1:G12491").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
    Workbooks("test.xls").Sheets("Sheet2").Range("A1:A5"), _
    Unique:=False
    and the range tomorrow might be ("G1:G13000")
    With other functions I can write "selection" at the beginning of the code and it will work like sort, function, but with this I could not manage it so far.

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Have you tried:
    [VBA]
    Range("G:G").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
    Workbooks("test.xls").Sheets("Sheet2").Range("A1:A5"), _
    Unique:=False

    [/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    this seems to work with a selection but I don't have your data so untested also:
    [VBA]With Selection
    .AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
    Workbooks("test.xls").Sheets("Sheet2").Range("A1:A5"), _
    Unique:=False
    End With[/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  6. #6

    thanks

    Quote Originally Posted by lucas
    this seems to work with a selection but I don't have your data so untested also:
    [vba]With Selection
    .AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
    Workbooks("test.xls").Sheets("Sheet2").Range("A1:A5"), _
    Unique:=False
    End With[/vba]
    thank you very much, that saved the day
    Last edited by yasarayhanka; 08-29-2007 at 11:09 AM.

Posting Permissions

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