Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Sort Question

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Sort Question

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Sort Question

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Sort Question

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Sort Question

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Sort Question

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
A question (sort of) Joe C Excel Discussion (Misc queries) 4 January 24th 08 03:03 PM
sort question D Excel Worksheet Functions 0 August 2nd 06 10:08 PM
Sort question pgruening Excel Discussion (Misc queries) 0 May 18th 06 08:22 PM
Sort Question G Excel Programming 3 September 8th 05 05:06 PM
sort question Romi Excel Discussion (Misc queries) 1 June 16th 05 11:25 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"