Solved

Excel number sorting macro problem

Posted on 2013-02-04
7
218 Views
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
0
Comment
Question by:MichaelGlancy
  • 5
  • 2
7 Comments
 
LVL 46

Expert Comment

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

Author Comment

by:MichaelGlancy
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
0
 
LVL 46

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.
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

Author Comment

by:MichaelGlancy
ID: 38853288
How do you record a macro ? (maybe thats another question?)
0
 
LVL 46

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.
0
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 38853327
Try this instead.
0
 
LVL 46

Expert Comment

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

Marty - MVP 2009 to 2012
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

810 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