View Full Version : 2003 sorting code not working in 2010

01-27-2016, 09:22 AM
Hi All
I've a bit of a wierd problem that i'm hoping someone can help me with.
I have the following code that runs a sort in a 2003 workbook.

Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Key2:=Range("A2") _
, Order2:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:=False _
, Orientation:=xlTopToBottom

In 2003 this works fine, however when run in 2010 if i add a new row of data at the bottom of the selected range (before running the macro) that new row gets sorted to the correct position but it has a row height of zero. To make it more infuriating if i use different data it works fine.
Has anyone come across something like this before?

01-27-2016, 10:24 AM
That code should work in Excel 2010 (it does here) but it depends on what's currently selected at the time of execution. Do you get an error message?
Regarding a row height of 0, do you have any other macros in the workbook, especially event-triggered ones, that could be operating on this? Look in the various modules, especially the Thisworkbook and the active sheet's code-module.
Do you have an Autofilter on the page?
If all else fails, post a workbook here (or link to one (omitting the http:// bit) if you aren't allowed to)