Excel 2016 error91 setting xlPrimary axis and xlSecondaryaxis to none

bastian18

New Member
Joined
Aug 15, 2018
Messages
22
Hello
I have a Chart in a Worksheet. In the Chart, I am trying to set xlPrimary axis and xlSecondaryaxis to none.
I opened the workbook in Excel and made the changes manually with the Recorder on.
This is the recorded macro code:
Code:
ActiveChart.Axes(xlValue, xlSecondary).Select
Selection.TickLabelPosition = xlNone

However, when I run the macro code VBA displays error91 in this line:
Code:
ActiveChart.Axes(xlValue, xlSecondary).Selec
VBA Run-time Error '91':confused:
Object-variable or With block variable are not set


Then I tried this code:
Code:
Dim ws As WorksheetDim ch As Chart


Set ch = ActiveChart
	With ch.Axes(xlValue, xlSecondary).Select
		Selection.TickLabelPosition = xlNone
	End With
Again VBA displays the same error:banghead: in this line:
Code:
 With ch.Axes(xlValue, xlSecondary).Select

Please, could anyone to help me to fix this error

Thanks in advance
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Upvote 0
Joe4
Your recommendation works fine:). Now, this is my code

Dim wb As Workbook
Dim ws As Worksheet
Dim mychart As ChartObject
Set wb = ThisWorkbook
Set ws = wb.Sheets("SheetName")
Set mychart = ws.ChartObjects("Chart 1")
With mychart.Chart
.Axes(xlValue, xlPrimary).TickLabelPosition = xlNone
.Axes(xlValue, xlSecondary).TickLabelPosition = xlNone
End With

My headache is gone
Thank you very much indeed
 
Upvote 0
You are welcome.
Glad I was able to help! :)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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