Av8tordude
Well-known Member
- Joined
- Oct 13, 2007
- Messages
- 1,074
- Office Version
- 2019
- Platform
- Windows
Book1 | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | |||
1 | PST | MST | CST | EST | ||||||||||
2 | LAS | LGB | ASE | TUS | AMA | DFW | ATL | SHV | ||||||
3 | LAX | SFO | CYS | ABQ | AUS | DAL | CAE | LCH | ||||||
4 | OAK | PSP | DEN | CRP | IAH | CLT | BTR | |||||||
5 | SAN | SMF | DRO | HOU | LBB | EWR | AEX | |||||||
6 | SEA | SJC | GJT | LNK | SAT | FLL | ||||||||
7 | GUC | MSP | GSO | |||||||||||
8 | LAS | OMA | JFK | |||||||||||
9 | PHX | ORD | LGA | |||||||||||
10 | SLC | STL | MCO | |||||||||||
Sheet1 |
Is there a way to sort the items automatically under each header.
ex.
Book1 | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | |||
1 | PST | MST | CST | EST | ||||||||||
2 | LAS | SJC | ABQ | SLC | AMA | SAT | ATL | LCH | ||||||
3 | LAX | ASE | TUS | AUS | STL | CAE | SHV | |||||||
4 | LGB | CYS | CRP | CLT | ||||||||||
5 | OAK | DEN | HOU | EWR | ||||||||||
6 | PSP | DRO | LBB | FLL | ||||||||||
7 | SAN | GJT | LNK | GSO | ||||||||||
8 | SEA | GUC | MSP | JFK | ||||||||||
9 | SFO | LAS | OMA | LGA | ||||||||||
10 | SMF | PHX | ORD | MCO | ||||||||||
Sheet1 |
I tried using this code but it does not sort the other columns under each header..
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Range("A2:C10").Sort Key1:=Range("A2"), Order1:=xlAscending, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
Range("D2:F10").Sort Key1:=Range("D2"), Order1:=xlAscending, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
Range("G2:I10").Sort Key1:=Range("G2"), Order1:=xlAscending, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
Range("J2:L10").Sort Key1:=Range("J2"), Order1:=xlAscending, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
End Sub
Last edited by a moderator: