Creating % of Grand Total for Selection.Subtotal formula

kyrgan

Active Member
Joined
Mar 23, 2006
Messages
309
Hello all,

I am using the following to create subtotals from a selection
Code:
    Range("B3:N1000").Select
    Selection.Subtotal GroupBy:=2, Function:=xlSum, _
    TotalList:=Array(5, 6, 7)
    ActiveSheet.Outline.ShowLevels RowLevels:=2

I need to add a column with the sales percentage: the Net Sales (Column 7) divided by the Grand Total (Last Row, Column 7) as a formula in Column 8 [% of sales]. Or even the results of this calculation there.

With the preceding code, what is nice this is I get a final new row that shows the Grand Total.

What I would like to do is when there is a Net Sales value in column 7 , to insert the formula =(Net Sale / Grand Total ). There is rarely the same number of rows so the Grand Total is rarely on the same row.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
hi

what about adding a formula in column 8 before the sub-totals are added =f2/(sum(f:f)*3

when adding sub-totals, add them to column 8 also

the solution relies on column F ultimately having the base data, and sub-totals and grand totals. So three times the base data

hth. regards
 
Upvote 0

Forum statistics

Threads
1,215,011
Messages
6,122,677
Members
449,092
Latest member
tayo4dgacorbanget

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top