Hi All, I'm stuck on the correct way to call "Chart 1" (Pivot Chart) on my worksheet to allow a change of major axis value when filters are changed. I keep getting errors at the red highlighted code. I have this and have tried these and many other arrangements but am getting nowhere.
Could someone please set me straight?
Private Sub Worksheet_PivotTableChangeSync(ByVal Target As PivotTable)
Dim mUnit As Long
If Cells(LastRow, LastCol) / LastCol - 1 >= 30 Then
mUnit = 10
Else
If Cells(LastRow, LastCol) / LastCol - 1 >= 200 Then
mUnit = 50
Else
If Cells(LastRow, LastCol) / LastCol - 1 >= 500 Then
mUnit = 100
End If
End If
End If
ActiveSheet.ChartObjects(1).Chart.Axes(xlValue).MajorUnit = mUnit
'or
ActiveSheet.Shapes("Chart 1").Axes(xlValue).MajorUnit = mUnit
End Sub
Many thanks,
Bookmarks