method majorunit of object axis failing Excel 2010 RRS feed

  • Question

  • Hello,

    While formatting my line chart, the following line of code fails:

           ActiveChart.Axes(xlCategory).MajorUnit = 12

    The sheet is not protected in any way.

    And this line of code was taken from a recorded macro, so no syntax issues.

    If I enter Debug window, Reset, and Run again with the Debug window open, it works.

    So this shows that there is nothing wrong with the code.

    Please help.

    Thank you

    Wednesday, October 23, 2013 11:36 AM

All replies

  • The category axis of a line chart only has a MajorUnit if the x-values are dates. If they are numbers of text strings, the MajorUnit property is invalid.

    Perhaps the TickMarkSpacing or TickLabelSpacing properties do what you want?

    (And, of course, you can only refer to ActiveChart if a chart has been selected)

    Regards, Hans Vogelaar (

    Wednesday, October 23, 2013 2:23 PM