Hi all,
I am getting a sort reference error and i cannot figure out why; there wasn't an issue yesterday!
"The sort reference is not valid. Make sure that it's within the data you want to sort, and the first Sort By box isn't the same or blank".
"Run-time error '1004':
Application-defined or object defined error"
on the .Apply
Thank you for all of your help!
I am getting a sort reference error and i cannot figure out why; there wasn't an issue yesterday!
"The sort reference is not valid. Make sure that it's within the data you want to sort, and the first Sort By box isn't the same or blank".
"Run-time error '1004':
Application-defined or object defined error"
on the .Apply
Rich (BB code):
Sub SortMyData()Dim MyDataFirstCell
Dim MyDataLastCell
Dim MySortCellStart
Dim MySortCellEnd
Range("A1").Select
MyDataFirstCell = ActiveCell.Address
Selection.End(xlDown).Select
Selection.End(xlToRight).Select
MyDataLastCell = ActiveCell.Address
Range("AB2").Select
MySortCellStart = ActiveCell.Address
Selection.End(xlDown).Select
MySortCellEnd = ActiveCell.Address
ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear
ActiveWorkbook.ActiveSheet.Sort.SortFields.Add _
Key:=Range(MySortCellStart & ":" & MySortCellEnd), Sorton:=xlSortOnValues, Order:=xlDescending, _
DataOption:=xlSortNormal
With ActiveWorkbook.ActiveSheet.Sort
.SetRange Range(MyDataFirstCell & ":" & MyDataLastCell)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Thank you for all of your help!