#1
|
|||
|
|||
Sorting elements in a row
Hello to everybody.
I am working with a 1000-rows matrix and i have to sort each of them in increasing order. Is there a method to make me avoid a thousand-times repetition of commands? Thank you. |
#2
|
|||
|
|||
Hi,
implement the macro below. First select the matrix you want to sort. Then run the macro. That should fix it. Kind regards Bjorn Sub Sort1() Dim rr As Integer, rng1 As Range, rng2 As Range, maxcol As Integer Set rng1 = Selection maxcol = rng1.Columns.Count For rr = 1 To rng1.Rows.Count Set rng2 = Range(rng1.Cells(rr, 1), rng1.Cells(rr, maxcol)) rng2.Sort Key1:=rng2.Cells(1, 1), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _ DataOption1:=xlSortNormal Next rr End Sub |
#3
|
|||
|
|||
Hi,
did it work? Kind regards Bjorn |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro for automatic sorting | Ziggy-R | Excel | 13 | 10-04-2010 06:57 PM |
MS Word to pdf - elements moved | SFC | Word | 1 | 05-25-2010 11:27 AM |
Sorting question | markg2 | Excel | 4 | 01-25-2010 03:13 PM |
Sorting Outlook TO: field | anakeimai | Outlook | 0 | 09-30-2009 06:15 AM |
sheet linking, sorting | nickbfe | Excel | 0 | 05-19-2006 11:00 AM |