Auto Sum Using VBA

Gaura215

Board Regular
Joined
Feb 2, 2011
Messages
97
Dear All

I have a wierd query here.

I am preparing a Pivot using a macro, and then I am require to make a table of that Pivot in a non-pivot format. please dont ask me why, company requirement lol. In that table, the last row is grand total for obvious reasons. Now this table width is fix, as the heading are fixed, but the table hight is not fixed, as it will have rows depending upon the size of the pivot table which get generated using my existing macro.
I am attaching the image of my table with this thread.


Using my knowledge and using this forum, I used the following code which is doing a sum total at the end of each numericals. But here is the problem, in case the cell above the grand total row is if blank, then it will give the total in that blank cell. but I want the total to comes only in the row which has grand total written.

Please help me out.

Sub Slide07_Global_AutoSum()

For Each NumRange In Columns("I:N").SpecialCells(xlConstants, xlNumbers).Areas
SumAddr = NumRange.Address(False, False)
NumRange.Offset(NumRange.Count, 0).Resize(1, 1).Formula = "=SUM(" & SumAddr & ")"
c = NumRange.Count
Next NumRange


NoData:
Call Slide06_SEMEA

End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,213,515
Messages
6,114,080
Members
448,548
Latest member
harryls

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