labels for subtotals

  • Thread starter Thread starter childofthe1980s
  • Start date Start date
C

childofthe1980s

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
 
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
 
Back
Top