I got this code which I want to run each time my OLAP pivot table (PT) changes, so that the formulae in columns K-L will re-size to match the size of the PT. I created a named range called ReceiptAnalysis and I used ="OFFSET(ReceiptAnalysis!$A$5,0,0,COUNTA(ReceiptAnalysis!$A:$A),10)" to make the range change depending on the size of the PT. I'm wondering if it's because it's an OLAP PT instead of a normal one and if this is the case, is there a different method I can use to make it run when the PT is updated?
PHP Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim iSect As Range
Set iSect = Application.Intersect(Target, Range("ReceiptAnalysis"))
If Not iSect Is Nothing Then
Call PivotMacro
End If
End Sub
Sub PivotMacro()
Dim ReceiptAnalysisSheet As Worksheet
Set ReceiptAnalysisSheet = Worksheets("ReceiptAnalysis")
With ReceiptAnalysisSheet
Lrows = .Cells(.Rows.Count, "K").End(xlUp).Row
.Range(.Cells(7, 11), .Cells(Lrows, "L")).ClearContents
End With
With ReceiptAnalysisSheet
.Range("K6:L6").AutoFill Destination:=.Range("K6:L" & .Range("J" & .Rows.Count).End(xlUp).Row)
End With
End Sub
Bookmarks