Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Dec 2009
    Location
    Bogangar NSW Australia
    Posts
    168
    Thanks
    37
    Thanked 3 Times in 2 Posts

    Excel 2010 VBA Run-Time Error '-2147467259 (80004005)': Setting Chart Axis

    Hi All,

    I have a very simple column chart on a single sheet workbook in which I'm attempting to set horizontal axis max and min values using vba and it keeps throwing the following error:

    20180606 Excel VBA Runtime error.JPG

    Here is the code causing the error:

    Code:
    Option Explicit
    
    
    Public Sub ChartTEST()
    
    
    Dim cht As Chart
    
    
    Set cht = Sheets("Sheet1").ChartObjects("Chart 1").Chart
    
    
    '   set minimum value for y-axis
    With cht.Axes(xlValue)
        .MinimumScale = 3
    End With
    
    
    '   set minium value for x-axis
    With cht.Axes(xlCategory)
        .MinimumScale = 0.9
    End With
    
    
    End Sub
    The code runs without error if I comment out the ".MinimumScale = 0" line following the line "With cht.Axes(xlCategory)".

    Here's my chart and its data:

    20180606 Excel VBA Runtime error Chart.JPG

    What am I missing? How do I prevent this error?

    Cheers

    Trevor
    Attached Images Attached Images
    Last edited by BygAuldByrd; 2018-06-05 at 21:16.

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    10,106
    Thanks
    441
    Thanked 1,637 Times in 1,477 Posts
    BAB,

    Cell B5 has a value < 0.9. Could be the problem?

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    2 Star Lounger
    Join Date
    Dec 2009
    Location
    Bogangar NSW Australia
    Posts
    168
    Thanks
    37
    Thanked 3 Times in 2 Posts
    Thanks for the suggestion but changing the value in B5, or any other value in column B, does not have any effect.

    The error message only occurs when I try to set the ".MinimumScale =..." or '.MaximumScale = ..." under the "With cht.Axes(xlCategory)". Those properties work correctly under "With cht.Axes(xlValue)".

    Cheers

    Trevor

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,436
    Thanks
    3
    Thanked 259 Times in 237 Posts
    A category axis is not numeric, therefore you can't set a minimum scale.
    Regards,
    Rory

  5. The Following User Says Thank You to rory For This Useful Post:

    BygAuldByrd (2018-06-07)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •