Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default sorting unknown range

Help...I am getting ERROR on ".Apply"
Sub Sort()
' Set Range for Sorting
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set Rng = Range("A11:J" & lastrow)

Rng.Select
Range("A11").Activate

ActiveSheet.Sort.SortFields.Clear
ActiveSheet.Sort.SortFields.Add _
Key:=Rng _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveSheet.Sort
.SetRange Rng
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default sorting unknown range

Hi,

Maybe this

Sub Sort()
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set Rng = Range("A11:J" & lastrow)
Rng.Select
Selection.Sort Key1:=Range("A11"), Order1:=xlDescending
End Sub

Mike


"Helmut" wrote:

Help...I am getting ERROR on ".Apply"
Sub Sort()
' Set Range for Sorting
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set Rng = Range("A11:J" & lastrow)

Rng.Select
Range("A11").Activate

ActiveSheet.Sort.SortFields.Clear
ActiveSheet.Sort.SortFields.Add _
Key:=Rng _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveSheet.Sort
.SetRange Rng
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub

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
Counting an Unknown Range atryon Excel Discussion (Misc queries) 1 May 5th 08 08:44 PM
sorting unknown range peyman Excel Discussion (Misc queries) 10 October 20th 07 08:34 PM
HELP! Unknown range Excel_Oz Excel Worksheet Functions 3 March 16th 07 01:35 AM
sorting through unknown source data as it is entered rldjda Excel Worksheet Functions 1 February 8th 07 01:03 AM
Sorting based on the first column of a defined name range (Unknown) PCLIVE Excel Programming 4 July 14th 05 04:35 PM


All times are GMT +1. The time now is 05:34 PM.

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

About Us

"It's about Microsoft Excel"