Sub total for dynamic range

praneetbvb

Board Regular
Joined
Aug 24, 2012
Messages
56
Hi I need to edit the formula for subtotaling in a dynamic range.



Sheet 1 : Standard: I need to subtotal in column B.

Here is the VBA code I am using;


Range("B1").Select
ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[2]C:R[10000]C)"

Can some help me edit the code, so that the formula works for any number of rows?



Sheet 1 : Standard: I need to total in column I

I need to total 2 different columns at the bottom of the pivot table. But the number of rows are not going to be same, so can some body please help me edit the code, so that if totals 2 columns as per the formula at the bottom of the pivot

Here is the code:

ActiveWindow.SmallScroll Down:=21
Range("F40").Select
ActiveCell.FormulaR1C1 = "Total"
ActiveCell.FormulaR1C1 = _
"=GETPIVOTDATA(""Calc Cost"",R3C1,""Cost"",""05-LO"")+GETPIVOTDATA(""Calc Cost"",R3C1,""Cost"",""04-MO"")"
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,215,035
Messages
6,122,785
Members
449,095
Latest member
m_smith_solihull

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