Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-03-2010, 02:00 AM
Riccardo Riccardo is offline Sorting elements in a row Windows XP Sorting elements in a row Office 2003
Novice
Sorting elements in a row
 
Join Date: Dec 2010
Posts: 1
Riccardo is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 12-05-2010, 07:52 AM
BjornS BjornS is offline Sorting elements in a row Windows Vista Sorting elements in a row Office 2003
Competent Performer
 
Join Date: Jan 2010
Location: Sweden
Posts: 116
BjornS is on a distinguished road
Default

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
Reply With Quote
  #3  
Old 12-14-2010, 10:08 AM
BjornS BjornS is offline Sorting elements in a row Windows Vista Sorting elements in a row Office 2003
Competent Performer
 
Join Date: Jan 2010
Location: Sweden
Posts: 116
BjornS is on a distinguished road
Default

Hi,
did it work?

Kind regards
Bjorn
Reply With Quote
Reply

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 elements in a row 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

Other Forums: Access Forums

All times are GMT -7. The time now is 11:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft