LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default bug in sort routines

There is a bug in my very simple sort routines that does not occur
consistently - and therefore baffles me. Perhaps I'm missing something
obvious.

In a tab containing essentially columns of numbers (percents), I have a
label defined as follows: citus=$a$11:$s$147. My intention is to create a
bunch of essentially identical sort routines which will sort this citus
selection according firstly to one of the columns from L to R in descending
order, and then secondly column F also in descending order - ie, the pairs of
sort orders are L+F, M+F, N+F, etc. Here is what one such routine looks like:

Sub sort_ctius_3m()
Application.Goto Reference:="ctius"
Selection.Sort Key1:=Range("P11"), Order1:=xlDescending, Key2:=Range( _
"F11"), Order2:=xlDescending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal
Range("P9").Select
End Sub

This routine was originally created via the "record macro" feature and I
just copied & pasted numerous of them and changed the SortKey1 and the
Range().Select to the columns I needed for each. They all reside in the same
"module".

The bug is: these sort routines work some times (say initially when the file
is opened) and then at some point (and I have no clue when this point will
show up) the routines would sort all rows in the citus selection EXCEPT the
first row. And then for unknown reasons, after running these sort routines a
few more times, they would start to work properly again.

If someone can point out to me what I'm doing wrong that would be very much
appreciated. Thanks.
 
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
Backup routines John in Wembley Excel Programming 1 November 17th 07 09:03 AM
VBA - sub routines Help please Richard Wrigley New Users to Excel 3 November 23rd 06 03:06 AM
VBA routines - help please Richard Wrigley Excel Discussion (Misc queries) 1 November 22nd 06 07:15 PM
Sorting Routines ADG Excel Programming 3 May 30th 06 10:30 AM
Calling sub routines Andrew[_49_] Excel Programming 2 June 30th 05 05:30 PM


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