Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sort Columns


Hi,

I have 6 columns and 5000 rows.
My headings a
a,b,c,d,e,f

I need to write a macro which sorts the cols in order:
a,c,d,b,e,f

It does need to be a macro, as opposed to manually doing a custom
list.
I have tried writing a macro which involves custom lists (below)
but doesnt quite work.

Thanks


Sub sortcol()

Range("A1:G12936").Sort Key1:=Range("A1"), Order1:=xlAscending,
Header:= _
xlGuess, OrderCustom:=6, MatchCase:=False,
Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
End Sub


--
T De Villiers
------------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479
View this thread: http://www.excelforum.com/showthread...hreadid=565980

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Sort Columns

Sub sortcol()

Range("A1:G12936").Sort Key1:=Range("A1"), Order1:=xlAscending, _
Key2:=Range("C1"), Order2:=xlAscending, _
Key3:=Range("D1"), Order3:=xlAscending, _
Header:=xlGuess, _
MatchCase:=False, _
Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
Range("A1:G12936").Sort Key1:=Range("B1"), Order1:=xlAscending, _
Key2:=Range("E1"), Order2:=xlAscending, _
Key3:=Range("F1"), Order3:=xlAscending, _
Header:=xlGuess, _
MatchCase:=False, _
Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
End Sub

--
Regards,
Tom Ogilvy


"T De Villiers" wrote:


Hi,

I have 6 columns and 5000 rows.
My headings a
a,b,c,d,e,f

I need to write a macro which sorts the cols in order:
a,c,d,b,e,f

It does need to be a macro, as opposed to manually doing a custom
list.
I have tried writing a macro which involves custom lists (below)
but doesnt quite work.

Thanks


Sub sortcol()

Range("A1:G12936").Sort Key1:=Range("A1"), Order1:=xlAscending,
Header:= _
xlGuess, OrderCustom:=6, MatchCase:=False,
Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
End Sub


--
T De Villiers
------------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479
View this thread: http://www.excelforum.com/showthread...hreadid=565980


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
Sort by color: Is there an easy way to sort columns or rows in EX MGP Excel Worksheet Functions 5 August 16th 08 11:28 AM
sort by two columns ends up with wrong sort in 2nd col urbnjckct Excel Discussion (Misc queries) 3 November 2nd 07 01:25 AM
Sort command does not sort some columns? BillyBob New Users to Excel 4 May 11th 06 04:16 PM
How do I sort the data in 8 columns by two of the columns? Sorting Excel Worksheet Functions 1 October 25th 05 03:57 PM
data sort is not including all columns in sort Tracy Excel Discussion (Misc queries) 1 October 4th 05 12:16 AM


All times are GMT +1. The time now is 10:01 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"