PrimaryValueAxisTitle error

ScottyWm

Board Regular
Joined
Jan 10, 2004
Messages
105
I'm at a loss... I used the VBA macro recorder to make a chart from a pivot table. Everything works fine except for one thing. I can not get a Title on the Primary Axis. The secondary axis, primary category, and Chart title all appear the way they should, but the PrimaryValueAxisTitle does not appear when I run the macro. Here's my code:

ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
ActiveChart.SetElement (msoElementPrimaryValueAxisTitleAdjacentToAxis)
ActiveChart.SetElement (msoElementSecondaryValueAxisTitleAdjacentToAxis)
ActiveChart.SetElement (msoElementChartTitleAboveChart)

Why doesn't it show up? I don't get an error when it executes that line. But I get an error when the code tries to add text to the element (because it isn't there).

Any help?
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
It's now 2021 and bug is still not fixed, but here is a workaround:
VBA Code:
With ActiveChart
    .SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
    .SetElement (msoElementPrimaryValueAxisTitleAdjacentToAxis)
    .SetElement (msoElementSecondaryValueAxisTitleAdjacentToAxis)
    .Axes(xlValue).HasTitle = True
    .Axes(xlSecondary).HasTitle = True
    .Axes(xlCategory).HasTitle = True
End With
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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