Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorting of sorts
Sorry for reposting but I did not get a workable solution the last time I
posted. I have tried on my own but as I am not very knowledgable in vba, got nowhere. I have an example sheet as below. I need to select 20 customers with the highest balances based on total balance, e.g, customer 1978 will need to total all 3 of his accounts. there is no way of knowing before hand how many accounts a customer has so I need to somehow (code please) add balances by customer. Then I need to select the 20 with the highest balances. In another workbook, is where I need to pick up the customer name, tax id etc.based on the custno. I can figure that one out. So please any help on the first part would be appreciated. custno atype bal 1978 040 567 1978 041 200 1978 042 8960 9102 010 3999 9102 040 2879 1973 010 1000 0192 655 234 0001 010 4000 0001 400 6000 9876 010 9000 -- Ruth_C |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorting of sorts
Hope this will help,
Sub Macro3() Selection.CurrentRegion.Select Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(3), _ Replace:=False, PageBreaks:=False, SummaryBelowData:=False Range("A1").Select Selection.CurrentRegion.Select ActiveSheet.Outline.ShowLevels RowLevels:=2 Selection.SpecialCells(xlCellTypeVisible).Select Selection.Copy Sheets(ActiveSheet.Name).Select Sheets.Add Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False Selection.Sort Key1:=Range("C2"), Order1:=xlDescending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Range("D1").Select ActiveCell.FormulaR1C1 = "Custno" Range("D2").Select ActiveCell.FormulaR1C1 = "=LEFT(RC[-3],FIND(""T"",RC[-3],1)-2)" Selection.Copy Range("D3:D8").Select ActiveSheet.Paste Application.CutCopyMode = False Range("D2").Select End Sub David "Ruth_C" wrote: Sorry for reposting but I did not get a workable solution the last time I posted. I have tried on my own but as I am not very knowledgable in vba, got nowhere. I have an example sheet as below. I need to select 20 customers with the highest balances based on total balance, e.g, customer 1978 will need to total all 3 of his accounts. there is no way of knowing before hand how many accounts a customer has so I need to somehow (code please) add balances by customer. Then I need to select the 20 with the highest balances. In another workbook, is where I need to pick up the customer name, tax id etc.based on the custno. I can figure that one out. So please any help on the first part would be appreciated. custno atype bal 1978 040 567 1978 041 200 1978 042 8960 9102 010 3999 9102 040 2879 1973 010 1000 0192 655 234 0001 010 4000 0001 400 6000 9876 010 9000 -- Ruth_C |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
DATA FOLLOWING SORTS | Excel Worksheet Functions | |||
sorting columns sorts header values too | Excel Discussion (Misc queries) | |||
Sum by different sorts | Excel Discussion (Misc queries) | |||
Sorts | Excel Worksheet Functions | |||
Need a spreadsheet that sorts by month/yr & 2 other sorts w/total | Excel Programming |