Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default 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
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
DATA FOLLOWING SORTS leejb Excel Worksheet Functions 0 August 20th 08 03:27 PM
sorting columns sorts header values too Matt Excel Discussion (Misc queries) 6 July 11th 08 07:52 PM
Sum by different sorts livetohike Excel Discussion (Misc queries) 2 November 5th 07 02:41 PM
Sorts Mona Marie Excel Worksheet Functions 3 July 21st 06 06:07 PM
Need a spreadsheet that sorts by month/yr & 2 other sorts w/total Spreadsheet[_2_] Excel Programming 1 May 19th 06 02:42 PM


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