Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Not even sure we need to worry about the range. I'm sure that the Sort will
pick the correct range provided you refer to a cell within the range, Hence: Sub SortOnA() Range("A1").Sort _ Key1:=Range("A1"), _ Order1:=xlAscending, _ Header:=xlGuess, _ OrderCustom:=1, _ MatchCase:=False, _ Orientation:=xlTopToBottom End Sub Seems to work OK in my brief test. If there is definitely a header we should declare "Header:= xlYes," or, if there's not, "Header:=xlNo," Regards Trevor "Patrick Molloy" wrote in message ... I suggest the following adjustment... Sub SelectRowsAndSortOnA() WITH Range("A1:B" & Range("A65536").End(xlUp).Row) .Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess .Name = "MyData" END WITH End Sub I dropped the .Select method. Having named the range, one can more easily use the table in other code -- Patrick Molloy Microsoft Excel MVP ---------------------------------- "polletje " wrote in message ... To be complete on your question: Sub SelectRowsAndSortOnA() Range("A1:B" & Range("A65536").End(xlUp).Row).Select Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom End Sub --- Message posted from http://www.ExcelForum.com/ |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find, Match data and paste data between two workbooks | Excel Discussion (Misc queries) | |||
Find formatting doesn't work: "Excel cannot find data" | Excel Discussion (Misc queries) | |||
Despite data existing in Excel 2002 spreadsheet Find doesn't find | Excel Discussion (Misc queries) | |||
The match and lookup functions can find literal data but not the same data referenced from a cell | Excel Discussion (Misc queries) | |||
FIND DATA WITHIN DATA (V-OR-H LOOKUP/FIND/MATCH?) | Excel Worksheet Functions |