I need help setting the X and Y axes title inside Excel 2007 VBA. It keeps complaining about “Object required”:
Sub macro2()
Dim xAxis As Axis
icount = 1
Charts.Add
Charts(icount).Name = iskewplane & "deg Skew Plane"
Charts(icount).Activate
Set xAxis = Charts(icount).Axes(xlCategory)
With xAxis
.Axis
.AxisTitle.Text = "Theta (deg)"
End With
Is there something wrong in my code? I tried recording the macro during setting the axis title name, but the macro is blank during the name setting.
Any help is appreciated
You should use
Option ExplicitbecauseiCountwasn’t defined andiskewplanewasn’t either.Here is the right code: