Results 1 to 4 of 4

Autofilter Sorting Macro

Threaded 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

    Autofilter Sorting Macro

    Hello - I recorded a Macro to autofilter a range of cells with data in it. I then tried to transcribe the recorded macro into my own code, but am having difficulty understanding why it does not work. It returns the following error: "Run-time error '424': Object required'. To give you an idea of what the spreadsheet looks like, I have a list of headers in row 1. The data is listed in columns A - Q and I'd like to sort by column L from largest to smallest value.

    Sub Sort()
             
        'Select Range of Cells
        Range("A1:Q1").Select
        
        'Clear Existing Filters
        Selection.AutoFilter.Sort.SortFields.Clear
       
        'Add Filter to Cell
        Selection.AutoFilter.Sort.SortFields.Add _
            Key:=Range("L1"), _
            SortOn:=xlSortOnValues, _
            Order:=xlDescending, _
            DataOption:=xlSortNormal
        
        'Apply Filter
        With Selection.AutoFilter.Sort
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
            
    End Sub
    Thanks in advance!
    Last edited by vba_beginner; 05-08-2013 at 05:06 PM.

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