Run time error '424'

wwrightchess

New Member
Joined
Apr 20, 2022
Messages
29
Office Version
  1. 365
Platform
  1. MacOS
I recorded the following macro but when I tried to run it again I get the error run time error '424' object required on the third line when it tries to set the axes title.

Sub Macro11()
'
' Macro11 Macro
'

'
Sheets("ff_plot").Select
ActiveChart.SetElement (msoElementPrimaryValueAxisTitleAdjacentToAxis)
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "Freezing Fraction"
Selection.Format.TextFrame2.TextRange.Characters.Text = "Freezing Fraction"
With Selection.Format.TextFrame2.TextRange.Characters(1, 17).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With
With Selection.Format.TextFrame2.TextRange.Characters(1, 17).Font
.BaselineOffset = 0
.Bold = msoFalse
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(89, 89, 89)
.Fill.Transparency = 0
.Fill.Solid
.Size = 10
.Italic = msoFalse
.Kerning = 12
.name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Strike = msoNoStrike
End With
ActiveChart.ChartArea.Select
End Sub
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
You need to add chart selection:
VBA Code:
Sheets("ff_plot").Select
   ActiveSheet.ChartObjects("WhichChart").Activate                '<<< ADD Here
   ActiveChart.SetElement (msoElementPrimaryValueAxisTitleAdjacentToAxis)
(macro recorder sometime fails)

Bye
 
Upvote 0
How do I get the name of the chart object? (The chart is on a sheet by itself)
 
Upvote 0
If you select the chart you will see its name in the "Names box" (just above the first column header); or use ChartObjects(1) if there is only one
 
Upvote 0
I tried ChartObjects(1) and got application-defined or object-defined-error.
I do nt see where there is a names box anywhere. I tried a screenshot but it said it was too large
 
Upvote 0
I tried ChartObjects(1) and got application-defined or object-defined-error
Which is the full line of code?

The Name box is the one in red, in the image
 

Attachments

  • NAME_Box_Immagine 2022-04-25 194612.jpg
    NAME_Box_Immagine 2022-04-25 194612.jpg
    24.6 KB · Views: 7
Upvote 0
Is there a ribbon I need to add? I still do not see what you refer to

Workbooks("combined_output.xlsx").Activate
Sheets("ff_plot").Select
ActiveSheet.ChartObjects(1).Activate
 
Upvote 0
The code is formally correct

If you don't see the name box (nor the formula bar) then try:
-Menu /File /Options /Advanced; scroll to "Display"; make sure that "Show the formula bar" is checked
 
Upvote 0
Would anyone know what this would translate to on mac?
I can find Preferences (not Options)
I see a formula bar but there is no name I can see
 
Upvote 0
Is the chart embedded within a worksheet? Or is it actually on a chart sheet?
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,937
Members
449,094
Latest member
teemeren

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