Sorting columns left to right leave a intact

T

Todd

I have a sheet with the following

column a = 3 digit zip

column b, c, d, & contain a text territory designation

a b c d e
Example: 917 SE/PR W7 W8 W9

I need the columns b to e to be sorted left to right
alphabetically.

so "701 SE8 SE7 E7"

would look like like

701 E7 SE7 SE8

the thing is that you may only have somethin in B or B&C
and then the rest blank.

We are leaving the column A thing where it is.

Thanks for your time.

Todd
 
D

David McRitchie

Hi Todd,
Always select your sort area ahead of time. If you rely on
Excel expanding a single cell to the current region
you will invariably get into trouble.
 
M

Medemper

Assuming your data starts in A1:

Sub SortHorizontal()
For j = 1 To Range("a1").End(xlDown).Row
Range(Cells(j, 2), Cells(j, 5)).Select
Selection.Sort Key1:=ActiveCell, Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight
Next j
End Sub

I have a sheet with the following

column a = 3 digit zip

column b, c, d, & contain a text territory designation

a b c d e
Example: 917 SE/PR W7 W8 W9

I need the columns b to e to be sorted left to right
alphabetically.

so "701 SE8 SE7 E7"

would look like like

701 E7 SE7 SE8

the thing is that you may only have somethin in B or B&C
and then the rest blank.

We are leaving the column A thing where it is.

Thanks for your time.

Todd
 
T

Todd

thansk will try tomarrow
-----Original Message-----
Assuming your data starts in A1:

Sub SortHorizontal()
For j = 1 To Range("a1").End(xlDown).Row
Range(Cells(j, 2), Cells(j, 5)).Select
Selection.Sort Key1:=ActiveCell, Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight
Next j
End Sub

"Todd" <[email protected]> wrote in
message news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top