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!
Bookmarks