ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SORT not working (https://www.excelbanter.com/excel-programming/381637-sort-not-working.html)

WLMPilot

SORT not working
 
On a different computer than my own, I created two sort routines via RECORD
MACRO. I then created a Command Button, copied & pasted the sort routine to
its appropriate command button. On the other computer, these routines worked
fine. However, when I loaded the Excel file onto my computer the routines do
not work.

I have other command buttons that continue to work properly on both computers.
I use MS Office 2000 Premium. I have not checked the version I used on the
other computer. However, since I used the "record" feature, I figured it
would be the same.

Here are both routines. The area that gets highlighted when I click on
debug is the
section that begins with "Selection.Sort" and ends with ":=xlSortNormal"

Private Sub CommandButton15_Click()
Range("A6:M48").Select
Selection.Sort Key1:=Range("C6"), Order1:=xlAscending, Key2:=Range("A6") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2 _
:=xlSortNormal
Range("A6").Select
End Sub

Private Sub CommandButton16_Click()
Range("A6:M48").Select
Selection.Sort Key1:=Range("A6"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ActiveWindow.SmallScroll Down:=-18
Range("A13:M48").Select
Selection.Sort Key1:=Range("C13"), Order1:=xlAscending,
Key2:=Range("A13" _
), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2 _
:=xlSortNormal
Range("A6").Select
End Sub

Any help is appreciated,
Les

Jim Cone

SORT not working
 
Les,

From the xl2000 help? file...
"expression.Sort(Key1, Order1, Key2, Type, Order2, Key3, Order3, Header, OrderCustom, MatchCase, Orientation, SortMethod)"

Note that there is no "DataOption" argument.
You should remove that section from your code.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"WLMPilot"
wrote in message
On a different computer than my own, I created two sort routines via RECORD
MACRO. I then created a Command Button, copied & pasted the sort routine to
its appropriate command button. On the other computer, these routines worked
fine. However, when I loaded the Excel file onto my computer the routines do
not work.

I have other command buttons that continue to work properly on both computers.
I use MS Office 2000 Premium. I have not checked the version I used on the
other computer. However, since I used the "record" feature, I figured it
would be the same.

Here are both routines. The area that gets highlighted when I click on
debug is the
section that begins with "Selection.Sort" and ends with ":=xlSortNormal"

Private Sub CommandButton15_Click()
Range("A6:M48").Select
Selection.Sort Key1:=Range("C6"), Order1:=xlAscending, Key2:=Range("A6") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2 _
:=xlSortNormal
Range("A6").Select
End Sub

Private Sub CommandButton16_Click()
Range("A6:M48").Select
Selection.Sort Key1:=Range("A6"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ActiveWindow.SmallScroll Down:=-18
Range("A13:M48").Select
Selection.Sort Key1:=Range("C13"), Order1:=xlAscending,
Key2:=Range("A13" _
), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2 _
:=xlSortNormal
Range("A6").Select
End Sub

Any help is appreciated,
Les


All times are GMT +1. The time now is 12:40 PM.

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