Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
labels for subtotals
Hello:
I'm going to create an Excel macro that, among other things, subtotals a column of numbers based on column B. Column B contains account numbers. (So, the macro will sort by column B, first.) I'd like for the row that shows the subtotal to have a distinct label. The label essentially will come from column C. Column C contains the account number description. This subtotal label will make it easier for the end user to understand what is being subtotaled. Is it possible to program a subtotal "label" in Excel? childofthe1980s |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
labels for subtotals
On Feb 21, 1:01*pm, childofthe1980s
wrote: Hello: I'm going to create an Excel macro that, among other things, subtotals a column of numbers based on column B. *Column B contains account numbers.. * (So, the macro will sort by column B, first.) I'd like for the row that shows the subtotal to have a distinct label. *The label essentially will come from column C. *Column C contains the account number description. This subtotal label will make it easier for the end user to understand what is being subtotaled. Is it possible to program a subtotal "label" in Excel? childofthe1980s The subtotal command automatically used the values in the selected column, so perhaps this will do your desire? Obviously need to adjust the range for your data. It sorts the range by column(B) ascending, then subtotals the range using a Sum function on column(C). Finally it auto-adjusts column(B)'s width to accommodate the subtotal titles. Sub test() With Range("B3:C16") .Sort Key1:=Range("B4"), Order1:=xlAscending, Header:=xlYes, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal .Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(2), _ Replace:=True, PageBreaks:=False, SummaryBelowData:=True End With Columns("B:B").EntireColumn.AutoFit End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can you change the text displayed on the labels a Pivot Tables'creates for subtotals? | Excel Discussion (Misc queries) | |||
Subtotals problem: Excel 2003 (not, AFAIK, the nested subtotals bug) | Excel Discussion (Misc queries) | |||
Copying Labels in Subtotals | Excel Discussion (Misc queries) | |||
Subtotals: Nested subtotals below higher subtotal | Excel Discussion (Misc queries) | |||
Problem with nested subtotals, placing secondary subtotals BELOW . | Excel Discussion (Misc queries) |