+ Reply to Thread
Results 1 to 2 of 2

Advancedfilter

  1. #1
    ram
    Guest

    Advancedfilter

    When i try and use advance filter in my code it will only filter if I
    activate the worksheet first.
    Is there away to use advance filter with out activating the worksheet.

    thanks for any help.



  2. #2
    NA
    Guest

    Re: Advancedfilter

    ram

    i'm not sure what your stuff looks like, but below is a snip i wrote earlier
    today that works. DATA and LIST are worksheet codenames.
    the purists will slam me for sloppy code - but it was a quick fix and it
    will give you the idea.
    perhaps the solution is to make sure you identify the range you want to
    filter.

    rgds - voodooJoe

    Private Sub Macro4()
    'set and advance filter selected range for unique values
    Set d =
    DATA.Range("I1").Resize(rowsize:=Application.WorksheetFunction.CountA(DATA.Columns(1).EntireColumn))
    d.AdvancedFilter Action:=xlFilterInPlace, Unique:=True

    'clear the target area
    LIST.Range("a1").CurrentRegion.Offset(1, 0).ClearContents

    'paste unique values to target area
    d.Copy
    LIST.Range("a1").PasteSpecial (xlPasteValues)

    'turn off filter and copy mode
    Application.CutCopyMode = False
    d.Parent.ShowAllData

    'sort the new list
    With LIST.Cells(1, 1)
    .CurrentRegion.Sort Key1:=.Cells(2, 1), Order1:=xlAscending,
    Header:=xlYes, OrderCustom:=1, _
    MatchCase:=False, Orientation:=xlTopToBottom,
    DataOption1:=xlSortNormal
    End With

    End Sub


    "ram" <[email protected]> wrote in message
    news:[email protected]...
    > When i try and use advance filter in my code it will only filter if I
    > activate the worksheet first.
    > Is there away to use advance filter with out activating the worksheet.
    >
    > thanks for any help.
    >
    >




+ 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