View Full Version : custom sorting a group of data
preseb
06-06-2011, 11:42 AM
I have my data broken out into 3 sections (under column D): M, P and Grouped. They are already sorted, so all of the M's are together, P's and Grouped.
What I am trying to do is, find all M's and custom sort that area. Same thing for P's and Grouped.
The data is from A:O
any help would be greatly appreciated.
thanks
CatDaddy
06-06-2011, 01:34 PM
how are you trying to sort them? more info
preseb
06-06-2011, 01:36 PM
by existing titles in column C.
e.g. apple, orange, grapes, banana, etc.
CatDaddy
06-06-2011, 01:46 PM
by existing titles in column C.
e.g. apple, orange, grapes, banana, etc.
'SET i = Worksheet number/title
ActiveWorkbook.Worksheets(i).Sort.SortFields.Clear
ActiveWorkbook.Worksheets(i).Sort.SortFields.Add Key:=Range("C1"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
With ActiveWorkbook.Worksheets(i).Sort
.SetRange Range("A:AF")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveWorkbook.Worksheets(i).Sort.SortFields.Clear
ActiveWorkbook.Worksheets(i).Sort.SortFields.Add Key:=Range("D1"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
With ActiveWorkbook.Worksheets(i).Sort
.SetRange Range("A:AF")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
sort column c first, then column d and c will remain sorted, but will rearrange by the d value
preseb
06-06-2011, 01:56 PM
Catdaddy, thanks for those details, but I don;t think it is going to do what I am trying.
I need to select in Column D all of the M's then say sort that range by Banana, Apple, Orange, Grapes.
Then find the P range and sort by the same custom listing: Banana, Apple, Orange, Grapes.
and again for Grouped
Thanks
Apple M
Orange M
Grapes M
Banana M
Apple P
Orange P
Grapes P
Banana P
Apple Grouped
Orange Grouped
Grapes Grouped
Banana Grouped
CatDaddy
06-06-2011, 01:59 PM
are you trying to send these to separate worksheets or something? this should group them the way you want, or if you need a custom order you can change the "Order"
preseb
06-07-2011, 06:11 AM
That worked perfectly - thank you
CatDaddy
06-07-2011, 10:19 AM
That worked perfectly - thank you
mark it as solved homie!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.