Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Paul, thanks for your prompt response.
Well it isnt just a data sort. Perhaps the example was to simplistic. Names Number (x names) 2 (y names) 1 (z names) 0 I want to sort alpabetically within each group. Also these lists are being pulled from a master list and thus the macro cannot be written with any specific numbers (eg 50 names associated with the number 2...this would imply a sort function, however i want to create a macro that will function independent of such specific information.....x names associated with 2, y with 1 etc). i hope this is clear, i really appreciate your help. here's what i tried initially, Dim n As Integer n = 0 Do If Cells(10 + n, 11) = 2 Then Range(Cells(10, 2), Cells(10 + n, 4)).Select Selection.Sort Key1:=Range("B:B"), Order1:=xlAscending, Header:=xlGuess_, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal End If n = n + 1 Loop End Sub the problem with this code is that it only works for the first group of numbers. havent used visual basic before and thus am having a hard time trying to code this. well hope this helps. thanks again "Paul Mathews" wrote: Arjun, perhaps I'm misunderstanding your question but isn't this just a data sort on the data range containing the two columns below where the primary sort field is "Number" and the secondary sort field is "Name" and both are sorted in ascending order? If so, click DataSort then indicate the two sort fields and ascending. "Arjun" wrote: I'm trying to sort within two groups. Here's an example: Name Number aw 2 ad 2 ce 1 fv 1 I am trying to sort the groups (with the number 2) alphabetically. I havent been able to figue out a macro that upon recognizing the 1 can highlight both the rows containing it. I do have a macro for the group '2', but would really appreciate it if someone can show me a more general one. thanks in advance |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sorting within Groups | Excel Discussion (Misc queries) | |||
Excel - Sorting groups in groups due to subtotaling | Excel Worksheet Functions | |||
Sorting Groups of Rows | Excel Discussion (Misc queries) | |||
Sorting with groups | Excel Discussion (Misc queries) | |||
Sorting by Groups | Excel Discussion (Misc queries) |