Sort 661 rows left to right

F

Frank Kabel

Hi
depending on your Excel version you can simply select all 661 rows and
goto 'Data - sort'. Click on 'Options' and select 'sort by columns'
 
F

Frank Kabel

Hi
then this should work. Select your data range and proceed as described
in my previous post
 
C

Carlton A. Barlow

Hello Frank,

When after hightlighting the range, selecting the option to sort left to right, only the first row of columns is sorted left to right. My issue is sorting the other 600 rows and their column contents, i.e.

c5 d5 e5 f5 g5
5 10 30 40 20 12
6 40 20 20 10 15
7 60 80 20 30 19
8 30 29 80 40 50

I want the rows 5-661 sorted left to right.

I hope this is helpful to my question.
 
D

Dave Peterson

How about something like this:

Option Explicit
Sub testme01()

Dim myRng As Range
Dim myRow As Range

With Worksheets("sheet1")
Set myRng = .Range("a5:AD661")
For Each myRow In myRng.Rows
With myRow
.Sort Key1:=.Cells(1), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlLeftToRight
End With
Next myRow
End With
End Sub

(Adjust those columns to match your data--I used a5:AD661).
 
D

Dave Peterson

Doh. Watch for linewrap!

Option Explicit
Sub testme01()

Dim myRng As Range
Dim myRow As Range

With Worksheets("sheet1")
Set myRng = .Range("a1:AD661")
For Each myRow In myRng.Rows
With myRow
.Sort Key1:=.Cells(1), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlLeftToRight
End With
Next myRow
End With
End Sub

<<snipped>>
 
Top