Run-time Error 91 Object Variable or With Block...

jampphan

New Member
Joined
Mar 4, 2020
Messages
2
Office Version
  1. 2016
I have upgrade to Excel 2016 and the VBA code we have been using for 20+ years is having issues. One piece of code that is giving me the Runtime Error 91 is the following. Any help to resolve would be appreciated.

Sub Chart2Update()
FormatChart2

ActiveSheet.Unprotect ("rm2000")
ChangeAuto:

ActiveChart.Axes(xlValue).Select --The debug brings me to this line as being the issue.
With ActiveChart.Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
ActiveSheet.Protect ("rm2000")
FormatChart1PC
End Sub
 

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.
You don't need that line of code. The following With statement gets you where you want to go. Just comment that line out or delete it. But I don't know what the "ChangeAuto:' label is for before that line. I don't see anything inthe code that refers to it.
 
Last edited:
Upvote 0
Didn't work. It just moved to the next line of code as being the error.
It appears to not like the ActiveChart syntax.
Make sure your chart is Active. If the chart has a name then maybe change ActiveChart to Charts("chart2"), using the actual chart name in the parentheses, of course.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

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