Sort horizontally

0

0-0 Wai Wai ^-^

Hi.
Normally when we do a sort, it is sorted vertically (ie straight down)
How about if I wish to sort a list of data horizontally?

Eg:
I have the following data in Row 1:
number -- 13 -- 23 -- 9 -- 45

I do a horizontal sort, so the data in Row 1 becomes:
number -- 9 -- 13 -- 23 -- 45

How to do?
 
K

kk

Hi

Select your range

Try ...

Data | Sort | Options | Left To Right

kk


Hi.
Normally when we do a sort, it is sorted vertically (ie straight down)
How about if I wish to sort a list of data horizontally?

Eg:
I have the following data in Row 1:
number -- 13 -- 23 -- 9 -- 45

I do a horizontal sort, so the data in Row 1 becomes:
number -- 9 -- 13 -- 23 -- 45

How to do?
 
0

0-0 Wai Wai ^-^

Hi

Select your range

Try ...

Data | Sort | Options | Left To Right

Thanks.
Is it possible to add these options in the toolbars?
To be specific, I would like to find their related icons (if any) when I
customize the toolbars.
So I can sort them easily with the click of the icon only.

If the above is not available, any other workaround is appreciated.
If I need to use macros, would you mind providing the scripts?
PS: Not sure if providing scripts for macros is tedious work or not. If so,
forget my request.
 
K

kk

Try this, untested

Sub SortByRow()
Dim rng As Range
Set rng = Selection

rng.Sort key1:=rng, Order1:=xlAscending, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlLeftToRight, DataOption1:=xlSortNormal
End Sub

kk

Hi

Select your range

Try ...

Data | Sort | Options | Left To Right

Thanks.
Is it possible to add these options in the toolbars?
To be specific, I would like to find their related icons (if any) when I
customize the toolbars.
So I can sort them easily with the click of the icon only.

If the above is not available, any other workaround is appreciated.
If I need to use macros, would you mind providing the scripts?
PS: Not sure if providing scripts for macros is tedious work or not. If so,
forget my request.
 
0

0-0 Wai Wai ^-^

Try this, untested

Sub SortByRow()
Dim rng As Range
Set rng = Selection

rng.Sort key1:=rng, Order1:=xlAscending, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlLeftToRight, DataOption1:=xlSortNormal
End Sub

Hi.
Is it possible that when I click on the macro, only the setting of
"Orientation:=xlLeftToRight" will change, other settings will remain unchanged?

I wonder this will do what I wish to do:
Sub SortByRow()
Dim rng As Range
Set rng = Selection
Orientation:=xlLeftToRight
End Sub
 
Top