Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default Sorting on more than one column

How can I sort numbers from 1-7 in column 'C' ascending and then sort the
dates in column 'A' in descending order for each group of numbers in 'C' with
one piece of code?

A C
15/08 2
14/08 3
16/08 2
17/08 3
16/08 3
15/08 1

Hope that makes sense!!

--
Traa Dy Liooar

Jock
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Sorting on more than one column

Try this:

Range("A1:C7").Select
Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:=Range("A2")
, Order2:=xlDescending, Header:=xlYes

You may have to change "Range("A1:C7")" to fit your data range.

HTH,
Matthew Pfluger

"Jock" wrote:

How can I sort numbers from 1-7 in column 'C' ascending and then sort the
dates in column 'A' in descending order for each group of numbers in 'C' with
one piece of code?

A C
15/08 2
14/08 3
16/08 2
17/08 3
16/08 3
15/08 1

Hope that makes sense!!

--
Traa Dy Liooar

Jock

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Sorting on more than one column


maybe something like this:

Sub sort_cols()
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
With ws.Range("A1:C7")
.Sort Key1:=ws.Range("C1"), Order1:=xlAscending, Key3:=ws.Range("A1") _
, Order3:=xlDescending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption3 _
:=xlSortNormal
End With
End Sub

--


Gary


"Jock" wrote in message
...
How can I sort numbers from 1-7 in column 'C' ascending and then sort the
dates in column 'A' in descending order for each group of numbers in 'C' with
one piece of code?

A C
15/08 2
14/08 3
16/08 2
17/08 3
16/08 3
15/08 1

Hope that makes sense!!

--
Traa Dy Liooar

Jock



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Sorting on more than one column

On Sep 28, 10:10 am, Jock wrote:
How can I sort numbers from 1-7 in column 'C' ascending and then sort the
dates in column 'A' in descending order for each group of numbers in 'C' with
one piece of code?

A C
15/08 2
14/08 3
16/08 2
17/08 3
16/08 3
15/08 1

Hope that makes sense!!

--
Traa Dy Liooar

Jock


Either

choose DataSort... and choose "Column C" (ascending) and 'then by'
"Column A" (descending)

or code:

Range("A1:C6").Select
Selection.Sort Key1:=Range("C1"), Order1:=xlAscending,
Key2:=Range("A1") _
, Order2:=xlDescending, Header:=xlGuess, OrderCustom:=1,
MatchCase:= _
False, Orientation:=xlTopToBottom

Brian Herbert Withun
---

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
Sorting a Pivot Table Column that is not the first column... [email protected] Excel Worksheet Functions 1 October 10th 07 09:02 PM
How do I limit sorting a column to the column? Pat Excel Worksheet Functions 0 February 9th 06 04:01 PM
Sorting 1 column into two jimF Excel Discussion (Misc queries) 5 February 1st 06 05:39 PM
Right column doesn't change when sorting left column. nohope Excel Discussion (Misc queries) 2 July 19th 05 03:27 PM
sorting a column Alex Excel Programming 3 April 22nd 05 12:04 AM


All times are GMT +1. The time now is 06:58 AM.

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"