Applying custom chart type

I

IgorM

Hi

I have a pivot-chart that I want to have it formatted with my custom chart
type. I have the type created (and saved) but I'm struggiling with the code
responsible for reapplying the type whenever user selectes different item
from the drop-down lists on the chart. I used a recorded code that is as
follows:
Private Sub Chart_Calculate()
ApplyCustomChartType
End Sub

Private Sub ApplyCustomChartType()
Application.Calculation = xlCalculationManual
ActiveChart.ApplyCustomType ChartType:=xlUserDefined, TypeName:= _
"Raport sprzeda¿y"
ActiveChart.Location Where:=xlLocationAsNewSheet
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
Application.Calculation = xlCalculationAutomatic
End Sub

Unfortunatelly the line ActiveChart.ApplyCustomType
ChartType:=xlUserDefined, TypeName:= "Raport sprzeda¿y" triggers the
Chart_Calculate event so the whole macro runs in endless loop.
How can fix this. Kind regards

Igor
 
S

Stefi

Try
Application.EnableEvents =False
at the beginning of the sub and set it back to True at the end.

Regards,
Stefi


„IgorM†ezt írta:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top