Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hie, I am trying to write a macro to sort rows of data according to th key in a specific column. Below is the code to sort the rows of dat according to the key in column E: Sub ColumnE() TotalRows = ActiveSheet.UsedRange.Rows.Count Range("A6:AZ" & TotalRows).Select Selection.Sort Key1:=Range("E6"), Order1:=xlAscending Key2:=Range("A6") _ , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1 MatchCase:= _ False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal DataOption2 _ :=xlSortNormal Range("E6").Select End Sub However, everytime the first row (in this case is Row 6) just would no be sorted. The second row (Row 7) onwards work fine. Can somebody please help! Many thank -- Jun-Chi ----------------------------------------------------------------------- Jun-Chih's Profile: http://www.excelforum.com/member.php...fo&userid=3521 View this thread: http://www.excelforum.com/showthread.php?threadid=54979 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jun, Change the "Header" variable in the sort method from
"Header:=xlGuess" to "Header:=xlNo". this should fix your problem... enjoy, Rick (Fairbanks, AK{Land of the Midnight Sun}) "Jun-Chih" wrote in message ... Hie, I am trying to write a macro to sort rows of data according to the key in a specific column. Below is the code to sort the rows of data according to the key in column E: Sub ColumnE() TotalRows = ActiveSheet.UsedRange.Rows.Count Range("A6:AZ" & TotalRows).Select Selection.Sort Key1:=Range("E6"), Order1:=xlAscending, Key2:=Range("A6") _ , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _ False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _ :=xlSortNormal Range("E6").Select End Sub However, everytime the first row (in this case is Row 6) just would not be sorted. The second row (Row 7) onwards work fine. Can somebody please help! Many thanks -- Jun-Chih ------------------------------------------------------------------------ Jun-Chih's Profile: http://www.excelforum.com/member.php...o&userid=35216 View this thread: http://www.excelforum.com/showthread...hreadid=549791 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Thanks Rick. It worked. Really appreciate your help. -- Jun-Chih ------------------------------------------------------------------------ Jun-Chih's Profile: http://www.excelforum.com/member.php...o&userid=35216 View this thread: http://www.excelforum.com/showthread...hreadid=549791 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Updating workbook with an alpha sort sheet and a numeric sort shee | Excel Discussion (Misc queries) | |||
sort function for dates does not sort properly in Office 2007 Exc. | Excel Worksheet Functions | |||
Pls. reply Sort Data and copy to next coulmn when sort order chang | Excel Programming | |||
Excel sort by Fill Color by custom list sort | Excel Discussion (Misc queries) | |||
sort (on part of) string - originally posted under Tricky Sort | Excel Programming |