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
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