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 Problem

excel 2007

what's wrong with the following sort?

Sub Macro1()

Range("B3").Select
lastrow = Range("B" & Rows.Count).End(xlUp).Row
Set SortRange = Rows("3:" & lastrow)
SortRange.Sort , key1:=Range("C2"), _
order1:=xlAscending, _
key2:=Range("B2"), _
order2:=xlAscending, _
Header:=xlYes

End Sub

It stops at SortRange.Sort
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Sorting Problem


What about this:

FirstRow = 2
lastrow = Range("B" & Rows.Count).End(xlUp).Row
Set SortRange = Range("B" & FirstRow & ":C" & lastrow)
SortRange.Sort Key1:=Range("C1"), Order1:=xlAscending, Key2:=Range("B1"),
Order2:=xlAscending, Header:=xlGuess

HTH,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Helmut" wrote:

excel 2007

what's wrong with the following sort?

Sub Macro1()

Range("B3").Select
lastrow = Range("B" & Rows.Count).End(xlUp).Row
Set SortRange = Rows("3:" & lastrow)
SortRange.Sort , key1:=Range("C2"), _
order1:=xlAscending, _
key2:=Range("B2"), _
order2:=xlAscending, _
Header:=xlYes

End Sub

It stops at SortRange.Sort

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
problem sorting ty Excel Worksheet Functions 2 June 16th 09 10:57 PM
sorting problem 10 comes before 8 ty Excel Worksheet Functions 2 June 16th 09 06:51 PM
Another sorting problem [email protected] Excel Discussion (Misc queries) 0 April 12th 07 09:37 PM
sorting problem Sadiwest Excel Discussion (Misc queries) 7 July 26th 06 04:02 PM
Sorting Problem Need James[_36_] Excel Programming 6 February 5th 05 07:02 AM


All times are GMT +1. The time now is 08:59 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"