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
Europa MacDonaldChief slayer of dragonsAsked:
Who is Participating?
 
Martin LissConnect With a Mentor Older than dirtCommented:
Try this instead.
0
 
Martin LissOlder than dirtCommented:
Works fine for me. What error do you get and what does your rows look like?
0
 
Europa MacDonaldChief slayer of dragonsAuthor Commented:
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
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Martin LissOlder than dirtCommented:
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.
0
 
Europa MacDonaldChief slayer of dragonsAuthor Commented:
How do you record a macro ? (maybe thats another question?)
0
 
Martin LissOlder than dirtCommented:
I don't have 2007 but here's an article that explains how.


Edit : Oops I see you use 2003. Be back soon.
0
 
Martin LissOlder than dirtCommented:
I'm glad I was able to help.

Marty - MVP 2009 to 2012
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.