Link to home
Start Free TrialLog in
Avatar of Europa MacDonald
Europa MacDonaldFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Excel number sorting macro problem

I have this macro to sort numbers into ascending order left to right on multiple rows.

Im getting a runtime error.

Could it be fixed ?

Public Sub SortRows()

   Dim Row As Range
   For Each Row In Selection.Rows
      Row.Sort Key1:=Row.Cells(1, 1), Order1:=xlAscending, Header:=xlNo, Orientation:=xlLeftToRight
   Next Row

End Sub
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Works fine for me. What error do you get and what does your rows look like?
Avatar of Europa MacDonald

ASKER

Run time error 1004

sort method of range class failed.

Im using 2003, could this be for a later version perhaps ?

columns A - F
random numbers in rows 1 - 80
All you probably need to do is to record a macro while you are doing what you want to do. If your range varies from time to time we can talk about that later.
How do you record a macro ? (maybe thats another question?)
I don't have 2007 but here's an article that explains how.


Edit : Oops I see you use 2003. Be back soon.
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm glad I was able to help.

Marty - MVP 2009 to 2012