+ Reply to Thread
Results 1 to 4 of 4

Autofilter Sorting Macro

Hybrid View

vba_beginner Autofilter Sorting Macro 05-08-2013, 04:58 PM
vba_beginner Re: Autofilter Sorting Macro 05-08-2013, 07:32 PM
vba_beginner Re: Autofilter Sorting Macro 05-08-2013, 07:57 PM
vba_beginner Re: Autofilter Sorting Macro 05-08-2013, 08:27 PM
  1. #1
    Registered User
    Join Date
    04-15-2013
    Location
    new york city
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Autofilter Sorting Macro

    According to another thread, you need to check if sheet is in AutoFilterMode? It seems to have done the trick! See "Andy Pope" answer:

    http://www.excelforum.com/excel-prog...e-not-set.html


    "Your code leaves the autofilter in place when either of the 2 routines runs.
    This means next time a routine is run the Autofilter command actually removes the autofilter which is why the clearing of the sort fails.
    You need to test for the autofilter being present are applying if not."


    Sub AutoFilter()
        
        Range("A83:Q83").Select
        Selection.AutoFilter
        If Not ActiveSheet.AutoFilterMode Then Selection.AutoFilter
        
        ActiveWorkbook.Worksheets("Portfolio by Week").AutoFilter.Sort.SortFields.Clear
        ActiveWorkbook.Worksheets("Portfolio by Week").AutoFilter.Sort.SortFields.Add _
            Key:=Range("L83"), _
            SortOn:=xlSortOnValues, _
            Order:=xlDescending, _
            DataOption:=xlSortNormal
        With ActiveWorkbook.Worksheets("Portfolio by Week").AutoFilter.Sort
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
        
    End Sub
    Last edited by vba_beginner; 05-08-2013 at 08:01 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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