VBA Calculations Update with Pivot table Changes

RunRabbit13

New Member
Joined
Aug 29, 2014
Messages
12
Hello,

First time posting, long-time user. I have searched far and wide to find a solution to the issue below. I am a novice in VBA but I am trying my best to get better.

I have a Pivot Table that will update based on the selection of the region. To the right of the Pivot Table are manual calculations (can't be done in calculated field as far a I can figure out) that update depending on the region selection. I would like the calculations to move with the Pivot Table when the user selects a region with less rows of data. I would also not like to calculate based on the Grand Total line. All I need is something to find the last row of the pivot and go up one to perform calculations.
I have this code held within the "This Workbook" area because I want it to be run when the user opens the file. Is that right?

Am I even in the ballpark here? Current code below:

Sub MonthoverMonth()
Dim strFormulas(1 To 6) As Variant
Dim Lrow As Long
With ThisWorkbook.Sheets("Zones")
strFormulas(1) = "=(C13/C12)-1"
strFormulas(2) = "=(D13/D12)-1"
strFormulas(3) = "=(E13/E12)-1"
strFormulas(4) = "=(F13/F12)-1"
strFormulas(5) = "=(G13/G12)-1"
strFormulas(6) = "=(H13/H12)-1"

.Range("I13:N13").Formula = strFormulas
.Range("I13:N19").FillDown
End With
End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,214,944
Messages
6,122,384
Members
449,080
Latest member
Armadillos

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