Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Sort Macro (2 levels)

The code below sorts column "A" but if I wanted to add a level to the sort
that would sort column "B".

How would I do that?

Range("data1").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlNo

Thanks
Carlos

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Sort Macro (2 levels)

try something like this

With Range("data1")
.Sort Key1:=.Range("A1"), Order1:=xlAscending, Key2:=.Range("B1") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=
_
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2 _
:=xlSortNormal
End With

--


Gary


"cgsteel" wrote in message
...
The code below sorts column "A" but if I wanted to add a level to the sort
that would sort column "B".

How would I do that?

Range("data1").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlNo

Thanks
Carlos



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Sort Macro (2 levels)

2 things:

watch the word-wrap and this will work in xl2003 and later.

--


Gary


"cgsteel" wrote in message
...
The code below sorts column "A" but if I wanted to add a level to the sort
that would sort column "B".

How would I do that?

Range("data1").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlNo

Thanks
Carlos



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro - security levels Becky Excel Discussion (Misc queries) 2 June 8th 07 03:02 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
How can I data sort to more than 3 levels Pam LaDue New Users to Excel 1 July 25th 06 09:25 PM
Do a data sort to more levels at once Pam LaDue Excel Discussion (Misc queries) 4 July 25th 06 09:21 PM
Set Security levels via macro J. Shrimp, Jr. Excel Programming 3 October 10th 03 01:43 PM


All times are GMT +1. The time now is 10:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"