Excel Sub-Totals : Getting the Percentages Calculating Correctly

Patrick O'Dea
Patrick O'Dea used Ask the Experts™
on
Hi,

See attached.
This shows sales by customer by country and the change this year VERSUS Last Year.

However, the % figure (in red) is wrong for obvious reasons.

Has Excel any clever way of getting this % figure correct.
I do NOT want to manually enter a new calculation formula if at all possible.


ExcelQueryAboutPercentages.xlsx
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi, 21Dewsbury.

I don't understand what you're looking for. The formula is incorrect. You want it corrected without changing it?

Regards,
Brian,
Hi,

this is a very strange request since the only way of getting the desired result is to use what you want to avoid. Manually inserting the correct formula.

But do not dispare, there is an easy way to do this since you have the formula already in the cell F2, you can just double click on the right bottom corner of that cell (the plus sign) and the formula will be copied down no efforts needed.

Have a nice day and good luck.

Author

Commented:
Hi folks,
Thanks for your contributions.
Let me clarify matters.
The example I have attached above is a simplified one.

In reality I have over 500 sub totals in this sheet.
I generate the sub-totals by using excels standard sub-total function.  This process takes about 10 seconds!!
However, in column F it is meaningless to sub-total the "% difference".  
I guess I require "The % Difference of the Sub-Totals" but I am getting "Sub-Total of the % Differences".

This should not be an odd request as it would arise in very many sheets of financial analysis.

To revert back to my example, I know that the USA spend $453 more dollars in 2011 than 2010.  This represents and increase of 31%. and not the 139% which is meaningless.

How do I get the 31% to display without typing 500 new formulas


Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

21Dewsbury,

The following code will convert the sub-totals formula in column F to the correct one...
Sub Fix_Subtotal()
Dim xLast_Row As Long
Dim xCell As Range

xLast_Row = ActiveSheet.Range("A1").SpecialCells(xlLastCell).Row

For Each xCell In Range("F2:F" & xLast_Row)
    If Left(xCell.Formula, 13) = "=SUBTOTAL(9,F" Then xCell.Formula = "=E" & xCell.Row & "/C" & xCell.Row
Next

End Sub

Open in new window

Regards,
Brian.
21Dewsbury,

Obviously, the above is hard-coded for this particular layout. If you're interested, it could be made more generic by passing it particular columns and having it replace any sub-totals formula by the equivalent of the one found in the preceding non-sub-total cell (or, more simply, the second row).

Regards,
Brian.

Author

Commented:
Thanks Brian, that will do nicely
Thanks, 21Dewsbury!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial