[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Excel number sorting macro problem

Posted on 2013-02-04
Medium Priority
Last Modified: 2013-02-13
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
Question by:Europa MacDonald
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
LVL 49

Expert Comment

by:Martin Liss
ID: 38853150
Works fine for me. What error do you get and what does your rows look like?

Author Comment

by:Europa MacDonald
ID: 38853205
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
LVL 49

Expert Comment

by:Martin Liss
ID: 38853248
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.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

by:Europa MacDonald
ID: 38853288
How do you record a macro ? (maybe thats another question?)
LVL 49

Expert Comment

by:Martin Liss
ID: 38853318
I don't have 2007 but here's an article that explains how.

Edit : Oops I see you use 2003. Be back soon.
LVL 49

Accepted Solution

Martin Liss earned 2000 total points
ID: 38853327
Try this instead.
LVL 49

Expert Comment

by:Martin Liss
ID: 38885816
I'm glad I was able to help.

Marty - MVP 2009 to 2012

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question