Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default How to leave Selection.Sort Key open....


Any way to change the sort key to be wherever cell it lands on in
column C?

Not limited to row number 73,74.....


Sub Macro1()

LastRowColA = Range("c65536").End(xlUp).Row

Range(Selection, Selection.End(xlToRight)).Select
Selection.Sort Key1:="R74C3", Order1:=xlDescending,
Type:=xlSortValues, _
OrderCustom:=1, Orientation:=xlLeftToRight
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default How to leave Selection.Sort Key open....

Jeremy,

Sub Macro2()
ActiveCell.CurrentRegion.Sort _
Key1:=Intersect(ActiveCell.CurrentRegion, ActiveCell.EntireRow).Cells(1, 1), _
Order1:=xlDescending, Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
End Sub

HTH,
Bernie
MS Excel MVP


"J.W. Aldridge" wrote in message
...

Any way to change the sort key to be wherever cell it lands on in
column C?

Not limited to row number 73,74.....


Sub Macro1()

LastRowColA = Range("c65536").End(xlUp).Row

Range(Selection, Selection.End(xlToRight)).Select
Selection.Sort Key1:="R74C3", Order1:=xlDescending,
Type:=xlSortValues, _
OrderCustom:=1, Orientation:=xlLeftToRight
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default How to leave Selection.Sort Key open....

Did you try ActiveCell?

"J.W. Aldridge" wrote:


Any way to change the sort key to be wherever cell it lands on in
column C?

Not limited to row number 73,74.....


Sub Macro1()

LastRowColA = Range("c65536").End(xlUp).Row

Range(Selection, Selection.End(xlToRight)).Select
Selection.Sort Key1:="R74C3", Order1:=xlDescending,
Type:=xlSortValues, _
OrderCustom:=1, Orientation:=xlLeftToRight
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default How to leave Selection.Sort Key open....

Didn't quite work....
Error message on
DataOption1:=xlSortNormal

Also, I still need it to use the last row used in the sheet, starting
with column C.

Thanx
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default How to leave Selection.Sort Key open....


Added the search code, but still......

Error on "DataOption1:=xlSortNormal".



Sub Macro99()

LastRowColA = Range("c65536").End(xlUp).Row

ActiveCell.CurrentRegion.Sort _
Key1:=Intersect(ActiveCell.CurrentRegion,
ActiveCell.EntireRow).Cells(1, 1), _
Order1:=xlDescending, Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
End Sub


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default How to leave Selection.Sort Key open....



This works for me, always sorting based on the last row of data:

Sub Macro99B()
Dim myC As Range

Set myC = Range("C65536").End(xlUp)
myC.CurrentRegion.Sort _
Key1:=myC, _
Order1:=xlDescending, Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
End Sub


--
HTH,
Bernie
MS Excel MVP


"J.W. Aldridge" wrote in message
...

Added the search code, but still......

Error on "DataOption1:=xlSortNormal".



Sub Macro99()

LastRowColA = Range("c65536").End(xlUp).Row

ActiveCell.CurrentRegion.Sort _
Key1:=Intersect(ActiveCell.CurrentRegion,
ActiveCell.EntireRow).Cells(1, 1), _
Order1:=xlDescending, Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
End Sub



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to leave Selection.Sort Key open....

DataOption# was added in xl2002 (IIRC). Just delete that portion from your
code.

"J.W. Aldridge" wrote:

Didn't quite work....
Error message on
DataOption1:=xlSortNormal

Also, I still need it to use the last row used in the sheet, starting
with column C.

Thanx


--

Dave Peterson
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
how do I toggle between 2 open excel files and leave both open Big D in Brighton Excel Discussion (Misc queries) 1 November 6th 08 04:28 PM
Can I use Sort to alphabetize & leave blank row bet. rows (2003) Sandy New Users to Excel 4 May 18th 08 05:31 PM
How do I sort collumns and leave out pictures in rows not used? TobyS. Excel Worksheet Functions 0 March 11th 08 10:16 PM
How do I sort values only, and leave formats? havocdragon Excel Programming 6 September 14th 06 02:32 PM
Can I sort values only & leave orginal cell formatting? Alyssa Excel Discussion (Misc queries) 1 March 8th 06 04:26 AM


All times are GMT +1. The time now is 10:25 AM.

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"