ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sort problem in Excel 2007 (https://www.excelbanter.com/excel-programming/422972-sort-problem-excel-2007-a.html)

Andrew Bourke

Sort problem in Excel 2007
 
Hi
I am testing macros that worked in Excel 2003 under Excel 2007.


In the program I use, rows from a list (across several cells) are
sometimes removed and I then use the sort line below to remove the blank
rows left in the list. This then produces the error message below.


'--- Do an alpha sort to remove blanked out lines
Shd.Range("B5:BB40").Sort Key1:=Shd.Range("B5"), Order1:=xlAscending


Error message:
"sort method of the range class failed error 1004"

Is there a simple way around this ?


Interesting:

1. After I 'End' the error message and get back to the page where the
blank rows are I can then sort the rows OK using a slightly different
sort routine (sorted numerically by total instead of alphabetically).


2. When re-running the code back under Excel 2003 I now get the same
error as first appeared in Excel 2007 !!

Ron Rosenfeld

Sort problem in Excel 2007
 
On Mon, 26 Jan 2009 08:03:40 +0900, Andrew Bourke wrote:

Hi
I am testing macros that worked in Excel 2003 under Excel 2007.


In the program I use, rows from a list (across several cells) are
sometimes removed and I then use the sort line below to remove the blank
rows left in the list. This then produces the error message below.


'--- Do an alpha sort to remove blanked out lines
Shd.Range("B5:BB40").Sort Key1:=Shd.Range("B5"), Order1:=xlAscending


Error message:
"sort method of the range class failed error 1004"

Is there a simple way around this ?


Interesting:

1. After I 'End' the error message and get back to the page where the
blank rows are I can then sort the rows OK using a slightly different
sort routine (sorted numerically by total instead of alphabetically).


2. When re-running the code back under Excel 2003 I now get the same
error as first appeared in Excel 2007 !!


I wonder if one of the optional Sort method parameters are somehow getting set
in such a way as to mess things up. Try setting them explicitly and see what
happens.

There were some new sort parameters added in 2007.
--ron

Andrew Bourke

Sort problem in Excel 2007
 

I've tried a workaround but all of a sudden it started working again -
WEIRD!

Thanks

On 26/01/2009 10:31 AM, Ron Rosenfeld wrote:
On Mon, 26 Jan 2009 08:03:40 +0900, Andrew wrote:

Hi
I am testing macros that worked in Excel 2003 under Excel 2007.


In the program I use, rows from a list (across several cells) are
sometimes removed and I then use the sort line below to remove the blank
rows left in the list. This then produces the error message below.


'--- Do an alpha sort to remove blanked out lines
Shd.Range("B5:BB40").Sort Key1:=Shd.Range("B5"), Order1:=xlAscending


Error message:
"sort method of the range class failed error 1004"

Is there a simple way around this ?


Interesting:

1. After I 'End' the error message and get back to the page where the
blank rows are I can then sort the rows OK using a slightly different
sort routine (sorted numerically by total instead of alphabetically).


2. When re-running the code back under Excel 2003 I now get the same
error as first appeared in Excel 2007 !!


I wonder if one of the optional Sort method parameters are somehow getting set
in such a way as to mess things up. Try setting them explicitly and see what
happens.

There were some new sort parameters added in 2007.
--ron



Ron Rosenfeld

Sort problem in Excel 2007
 
On Mon, 26 Jan 2009 20:23:34 +0900, Andrew Bourke wrote:

I've tried a workaround but all of a sudden it started working again -
WEIRD!


I've not tested the Sort method, but I know that with some methods, the
optional parameters, once set, stay at that setting until changed. So I still
wonder if that was the issue. If so, it could recur.
--ron


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com