Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7
Default Sort each line horizontally and separately

I have a worksheet with 200 lines. I would like to sort each line
horizontally, so that the lowest number in each line is represented in column
A, and the second lowest number in column B and so on. Can this be done for
all the lines at the same time?


Before sorting
A B C
Line 1 2 1 7
Line 2 5 8 1

After sorting
A B C
Line 1 1 2 7
Line 2 1 5 8
--
Best regards

Nils
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sort each line horizontally and separately

Assume your source data is running in A1:C1 down
In say, E1: =SMALL($A1:$C1,COLUMNS($A:A))
Copy across to G1, fill down as far as required to return desired results
Any good? hit the YES below
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:27,000 Files:200 Subscribers:70
xdemechanik
---
"nils" wrote:
I have a worksheet with 200 lines. I would like to sort each line
horizontally, so that the lowest number in each line is represented in column
A, and the second lowest number in column B and so on. Can this be done for
all the lines at the same time?


Before sorting
A B C
Line 1 2 1 7
Line 2 5 8 1

After sorting
A B C
Line 1 1 2 7
Line 2 1 5 8
--
Best regards

Nils

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Sort each line horizontally and separately

Select the 200 rows then run this macro.

Edit to suit.

Sub SortRows()
'Tom Ogilvy macro
Dim r As Long
Dim lRow As Long

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
lRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row

'Make the r = 1 whatever the first row of data you want to sort on is.
'The Cells(r, 1) means your data starts in Col 1 or Col A - adjust as
'necessary
'The resize(1, 7) expands the range to 1 cell deep by 7 cells wide

For r = 1 To lRow
With Cells(r, 1).Resize(1, 7)
.Sort Key1:=Cells(r, 2), Order1:=xlAscending, Header:=xlGuess, _
Orientation:=xlLeftToRight, DataOption1:=xlSortNormal
End With
Next r

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub


Gord Dibben MS Excel MVP

On Mon, 21 Sep 2009 04:39:01 -0700, nils
wrote:

I have a worksheet with 200 lines. I would like to sort each line
horizontally, so that the lowest number in each line is represented in column
A, and the second lowest number in column B and so on. Can this be done for
all the lines at the same time?


Before sorting
A B C
Line 1 2 1 7
Line 2 5 8 1

After sorting
A B C
Line 1 1 2 7
Line 2 1 5 8


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i sort 2 colums so that the same values line up odi et amo Excel Discussion (Misc queries) 2 February 2nd 09 09:50 AM
Can I sort horizontally? Mac[_3_] Excel Discussion (Misc queries) 4 July 20th 08 10:10 PM
Sort horizontally? Niniel Excel Discussion (Misc queries) 8 October 6th 07 03:02 AM
resize line or arrow shape horizontally in Excel 2007 David Excel Discussion (Misc queries) 2 September 4th 07 11:18 AM
a blue line running horizontally through a few cells what is it Dalt New Users to Excel 1 May 17th 05 02:41 AM


All times are GMT +1. The time now is 12:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"