Does my secondary axis exist?

ajwillshire

New Member
Joined
Mar 4, 2009
Messages
31
Hi,

I've got a routine which builds up a chart using VBA using values created in a table. In the table the user has the option of plotting a series on the primary or secondary axis and it will be assigned there using the .Axisgroup property.

So far so good.

However, I want to add titles to the axes which is easy for the category axis and the primary value axis. The problem is checking if the secondary axis has been created or not. If it hasn't been created and my code tries to edit it then I get an error.

I guess I could resolve this with just an "On error, resume next" but ideally I'd like a line of code which will tell me if the axis exists so that I can exclude the formatting using an If statement.

Can anyone help?

Many thanks in advance,

Andrew
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
If the user has an option to plot on a primary or secondary axis then there must be a user input eg option button/checkboxes. Set up a boolean operator based on the user's selection, then use this as a condition for formatting the secondary axis or not as appropriate
 
Upvote 0
Thanks. I can easily check the row in the table to see if the user has entered "2" anywhere - perhaps I'm trying to be too clever.

Just for my own learning though, is there any way to test if the axis exists (or other similar objects)?
 
Upvote 0
Not really. You can test the Axes.Count but it is possible to have only 2 Y axes for example, so it's not definitive. I use an error handler. :)
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

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