Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I want to use the following code to sort a worksheet (Employee_List), but I
do not want the sorted worksheet to be active: Range("A3:D300").Select Selection.Sort Key1:=Range("D4"), Order1:=xlAscending, Key2:=Range("A4") _ , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=2, MatchCase:= _ False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _ :=xlSortNormal Range("A3").Select |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
this doesn't have to have the sheet active
Option Explicit Sub sort() Dim wks As Worksheet Set wks = Worksheets("sheet1") With wks.Range("A3:D300") ..sort Key1:=wks.Range("D4"), Order1:=xlAscending, Key2:=wks.Range("A4"), _ Order2:=xlAscending, Header:=xlGuess, OrderCustom:=2, MatchCase:= _ False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _ :=xlSortNormal Range("A3").Select End With End Sub -- Gary "Patrick Simonds" wrote in message ... I want to use the following code to sort a worksheet (Employee_List), but I do not want the sorted worksheet to be active: Range("A3:D300").Select Selection.Sort Key1:=Range("D4"), Order1:=xlAscending, Key2:=Range("A4") _ , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=2, MatchCase:= _ False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _ :=xlSortNormal Range("A3").Select |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
OK this is exactly what I put in, but it did not do anything:
Option Explicit Sub sort() Dim wks As Worksheet Set wks = Worksheets("Employee_List") With wks.Range("A3:D300") ..sort Key1:=wks.Range("D4"), Order1:=xlAscending, Key2:=wks.Range("A4"), _ Order2:=xlAscending, Header:=xlGuess, OrderCustom:=2, MatchCase:= _ False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _ :=xlSortNormal Range("A3").Select End With End Sub "Gary Keramidas" <GKeramidasATmsn.com wrote in message ... this doesn't have to have the sheet active Option Explicit Sub sort() Dim wks As Worksheet Set wks = Worksheets("sheet1") With wks.Range("A3:D300") .sort Key1:=wks.Range("D4"), Order1:=xlAscending, Key2:=wks.Range("A4"), _ Order2:=xlAscending, Header:=xlGuess, OrderCustom:=2, MatchCase:= _ False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _ :=xlSortNormal Range("A3").Select End With End Sub -- Gary "Patrick Simonds" wrote in message ... I want to use the following code to sort a worksheet (Employee_List), but I do not want the sorted worksheet to be active: Range("A3:D300").Select Selection.Sort Key1:=Range("D4"), Order1:=xlAscending, Key2:=Range("A4") _ , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=2, MatchCase:= _ False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _ :=xlSortNormal Range("A3").Select |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
if sheet 2 is the active sheet and run this, it sorts the employee_list
sheet test data i have. are you sure the sort keys are correct? -- Gary "Patrick Simonds" wrote in message ... OK this is exactly what I put in, but it did not do anything: Option Explicit Sub sort() Dim wks As Worksheet Set wks = Worksheets("Employee_List") With wks.Range("A3:D300") .sort Key1:=wks.Range("D4"), Order1:=xlAscending, Key2:=wks.Range("A4"), _ Order2:=xlAscending, Header:=xlGuess, OrderCustom:=2, MatchCase:= _ False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _ :=xlSortNormal Range("A3").Select End With End Sub "Gary Keramidas" <GKeramidasATmsn.com wrote in message ... this doesn't have to have the sheet active Option Explicit Sub sort() Dim wks As Worksheet Set wks = Worksheets("sheet1") With wks.Range("A3:D300") .sort Key1:=wks.Range("D4"), Order1:=xlAscending, Key2:=wks.Range("A4"), _ Order2:=xlAscending, Header:=xlGuess, OrderCustom:=2, MatchCase:= _ False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _ :=xlSortNormal Range("A3").Select End With End Sub -- Gary "Patrick Simonds" wrote in message ... I want to use the following code to sort a worksheet (Employee_List), but I do not want the sorted worksheet to be active: Range("A3:D300").Select Selection.Sort Key1:=Range("D4"), Order1:=xlAscending, Key2:=Range("A4") _ , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=2, MatchCase:= _ False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _ :=xlSortNormal Range("A3").Select |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Got it to work, At the end of the .sort line it should have been B4 not A4.
Thanks for your help. "Gary Keramidas" <GKeramidasATmsn.com wrote in message ... this doesn't have to have the sheet active Option Explicit Sub sort() Dim wks As Worksheet Set wks = Worksheets("sheet1") With wks.Range("A3:D300") .sort Key1:=wks.Range("D4"), Order1:=xlAscending, Key2:=wks.Range("A4"), _ Order2:=xlAscending, Header:=xlGuess, OrderCustom:=2, MatchCase:= _ False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _ :=xlSortNormal Range("A3").Select End With End Sub -- Gary "Patrick Simonds" wrote in message ... I want to use the following code to sort a worksheet (Employee_List), but I do not want the sorted worksheet to be active: Range("A3:D300").Select Selection.Sort Key1:=Range("D4"), Order1:=xlAscending, Key2:=Range("A4") _ , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=2, MatchCase:= _ False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _ :=xlSortNormal Range("A3").Select |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
you're welcome, glad you got it working
-- Gary "Patrick Simonds" wrote in message ... Got it to work, At the end of the .sort line it should have been B4 not A4. Thanks for your help. "Gary Keramidas" <GKeramidasATmsn.com wrote in message ... this doesn't have to have the sheet active Option Explicit Sub sort() Dim wks As Worksheet Set wks = Worksheets("sheet1") With wks.Range("A3:D300") .sort Key1:=wks.Range("D4"), Order1:=xlAscending, Key2:=wks.Range("A4"), _ Order2:=xlAscending, Header:=xlGuess, OrderCustom:=2, MatchCase:= _ False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _ :=xlSortNormal Range("A3").Select End With End Sub -- Gary "Patrick Simonds" wrote in message ... I want to use the following code to sort a worksheet (Employee_List), but I do not want the sorted worksheet to be active: Range("A3:D300").Select Selection.Sort Key1:=Range("D4"), Order1:=xlAscending, Key2:=Range("A4") _ , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=2, MatchCase:= _ False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _ :=xlSortNormal Range("A3").Select |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
A question (sort of) | Excel Discussion (Misc queries) | |||
sort question | Excel Worksheet Functions | |||
Sort question | Excel Discussion (Misc queries) | |||
Sort Question | Excel Programming | |||
sort question | Excel Discussion (Misc queries) |