Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Sorting data in rows

I probably should know how to do this but i can't figure it out. I have a
database with patient codes in up to 20 columns. I want each row to sort the
data that goes across the 20 columns. for example: (using numbers saved as
text)

PatA 1 5 4 3 2
PatB 5 4 1 6 7
PatC 8 7 3 2 1

Would look like:

PatA 1 2 3 4 5
PatB 1 4 5 6 7
PatC 1 2 3 7 8

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Sorting data in rows

Try:-

Select your data.

Data|sort|options|sort left to right

Mike

"LT_childrens" wrote:

I probably should know how to do this but i can't figure it out. I have a
database with patient codes in up to 20 columns. I want each row to sort the
data that goes across the 20 columns. for example: (using numbers saved as
text)

PatA 1 5 4 3 2
PatB 5 4 1 6 7
PatC 8 7 3 2 1

Would look like:

PatA 1 2 3 4 5
PatB 1 4 5 6 7
PatC 1 2 3 7 8

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Sorting data in rows

thanks Mike, i tried that already, but because it asks which field to sort by
it will sort everything still by one row. Meaning, the first row will be
correct but the others will just move according to the first row. I need each
row to sort individually. Does that make sense?

"Mike H" wrote:

Try:-

Select your data.

Data|sort|options|sort left to right

Mike

"LT_childrens" wrote:

I probably should know how to do this but i can't figure it out. I have a
database with patient codes in up to 20 columns. I want each row to sort the
data that goes across the 20 columns. for example: (using numbers saved as
text)

PatA 1 5 4 3 2
PatB 5 4 1 6 7
PatC 8 7 3 2 1

Would look like:

PatA 1 2 3 4 5
PatB 1 4 5 6 7
PatC 1 2 3 7 8

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Sorting data in rows

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

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Lrow = ActiveSheet.Cells(Rows.Count, "B").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, 4) expands the range to 1 cell deep by 4 cells wide

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

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub

Since you have 5 columns change the resize to 1 ,5 and to leave column A out of
the mix change r ,1 to r , 2


Gord Dibben MS Excel MVP

On Tue, 29 May 2007 09:32:00 -0700, LT_childrens
wrote:

thanks Mike, i tried that already, but because it asks which field to sort by
it will sort everything still by one row. Meaning, the first row will be
correct but the others will just move according to the first row. I need each
row to sort individually. Does that make sense?

"Mike H" wrote:

Try:-

Select your data.

Data|sort|options|sort left to right

Mike

"LT_childrens" wrote:

I probably should know how to do this but i can't figure it out. I have a
database with patient codes in up to 20 columns. I want each row to sort the
data that goes across the 20 columns. for example: (using numbers saved as
text)

PatA 1 5 4 3 2
PatB 5 4 1 6 7
PatC 8 7 3 2 1

Would look like:

PatA 1 2 3 4 5
PatB 1 4 5 6 7
PatC 1 2 3 7 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
Sorting Data and Keeping format of rows Luci Excel Discussion (Misc queries) 0 May 24th 07 06:38 AM
Sorting rows of repetitive data S R Burns New Users to Excel 1 April 30th 07 07:33 PM
sorting rows of data AbeAbeAbe Excel Discussion (Misc queries) 7 February 21st 07 02:49 PM
Sorting 4 rows of data and changing the text of the highest value. AbeAbeAbe Excel Discussion (Misc queries) 2 February 17th 07 05:54 PM
Sorting data rows independently guillemot Excel Discussion (Misc queries) 0 December 22nd 05 04:54 AM


All times are GMT +1. The time now is 06:24 AM.

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"