View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jo[_2_] Jo[_2_] is offline
external usenet poster
 
Posts: 69
Default Sorting row data?!

On Aug 15, 10:22 am, Vergel Adriano
wrote:
I asssume you want to sort each row, from left to right and that you're
looking for a macro to do that. Here's one way:

Sub test()
Dim r As Range

For Each r In ActiveSheet.UsedRange.Rows
r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending,
Orientation:=xlLeftToRight
Next r
End Sub

--
Hope that helps.

Vergel Adriano



"Jo" wrote:
Hi everyone,


I know how to sort data by row, but say I have 5000 or more rows!
Going to each row and doing the sorting is time-consuming.


Is there a smart way to do this one time?


Thanks,
Jo- Hide quoted text -


- Show quoted text -


Vergel,

Are you sure it is correct? I am getting these two rows in RED:

r.Sort key1:=r.Cells(1, 1), Order1:=xlAscending,
Orientation:=xlLeftToRight