Hello Guys,
I have a Pivot table, where i need to add new row above the pivot table and show the subtotal of each column till last available Column. (Pivot range may vary)
Below is the code which i tried but it was not working correctly. Please help.
I have a Pivot table, where i need to add new row above the pivot table and show the subtotal of each column till last available Column. (Pivot range may vary)
Below is the code which i tried but it was not working correctly. Please help.
VBA Code:
LR = ActiveSheet.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
LC = ActiveSheet.Cells.Find("*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
LCell = Cells(LR, LC).Address
myrange = "C10:" & LCell
Subtotal = ""
Range(myrange).Select
If Range("E" & LC).Value <> "" Then
Range("E7" & LC).Formula = "=SUBTOTAL(9 & LR & )"
End If