ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error Message: Sort Method of Range Class Failed (https://www.excelbanter.com/excel-programming/431958-error-message-sort-method-range-class-failed.html)

munchkin

Error Message: Sort Method of Range Class Failed
 
I want my marco button to sort my POLICYLIST named range by A5, then by P5,
but it's not working. What am I doing wrong?

Application.Goto Reference:="POLICYLIST"
Selection.Sort Key1:=Range("A5"), Order1:=xlAscending, Key2:=Range("P5") _
, Order2:=xlAscending, Header:=xlNo, OrderCustom:=1,
MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:= _
xlSortNormal
Range("B5").Select
End Sub



munchkin

Error Message: Sort Method of Range Class Failed
 
I feel so silly - disregard my question - I figured it out. My worksheet is
protected & I forgot to tell my macro to unprotect my worksheet first.

"Munchkin" wrote:

I want my marco button to sort my POLICYLIST named range by A5, then by P5,
but it's not working. What am I doing wrong?

Application.Goto Reference:="POLICYLIST"
Selection.Sort Key1:=Range("A5"), Order1:=xlAscending, Key2:=Range("P5") _
, Order2:=xlAscending, Header:=xlNo, OrderCustom:=1,
MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:= _
xlSortNormal
Range("B5").Select
End Sub



ryguy7272

Error Message: Sort Method of Range Class Failed
 
Something definitely doesn't seem right. Is A5 and P5 inside the POLICYLIST?
Ryan--

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Munchkin" wrote:

I want my marco button to sort my POLICYLIST named range by A5, then by P5,
but it's not working. What am I doing wrong?

Application.Goto Reference:="POLICYLIST"
Selection.Sort Key1:=Range("A5"), Order1:=xlAscending, Key2:=Range("P5") _
, Order2:=xlAscending, Header:=xlNo, OrderCustom:=1,
MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:= _
xlSortNormal
Range("B5").Select
End Sub




All times are GMT +1. The time now is 07:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com