+ Reply to Thread
Results 1 to 8 of 8

Problem adding Y axis Title

  1. #1
    Registered User
    Join Date
    11-15-2011
    Location
    St. Louis, MO
    MS-Off Ver
    Excel 2013
    Posts
    69

    Smile Problem adding Y axis Title

    I recorded a macro to add axis titles. All of the axis titles appeared after recording the macro. The code appears below. However after recording this macro, I deleted my chart sheet, then recreate it, then tried to run my 'Add_Axis_Titles' macro. It stepped through until I got to the line:

    Selection.Caption = "Battery %"

    Where I got the error: Run-time error '424': Object Required

    I could see where the Text box for the secondary Y axis is, and I could see where the X axis title was set to "Time", but the primary Y axis text box was nowhere to be found. I have tried moving the chart, thinking it may be out of sight, but it's not there. I have also recreated the chart and tried manually to add axis titles again, and I was able to add all of the axis titles manually. Does anyone have any Ideas about this?
    Please Login or Register  to view this content.
    So it appears there is something wrong with:
    Please Login or Register  to view this content.
    Steve
    Last edited by sdingman; 08-28-2017 at 11:48 AM. Reason: I found that I could add the Y axis Title manually.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Problem adding Y axis Title

    I am not sure what the problem is but I would not select everything to set it; you can reference it directly. This may not help but is a cleaner method.
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    11-15-2011
    Location
    St. Louis, MO
    MS-Off Ver
    Excel 2013
    Posts
    69

    Re: Problem adding Y axis Title

    6StringJazzer, Thank you for your response. I pasted what you suggested into the macro, and remmed out what I had. I got exactly the same error. I think I'll try to put a Y axis title only, see what I get.

  4. #4
    Registered User
    Join Date
    11-15-2011
    Location
    St. Louis, MO
    MS-Off Ver
    Excel 2013
    Posts
    69

    Re: Problem adding Y axis Title

    When I ran only the code to place a Y axis title, by itself, I got the same error. The Y axis Text Box is just not appearing after the line:
    Please Login or Register  to view this content.
    Any thoughts as to what might be happening? Is there a test I could perform maybe?
    Steve

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Problem adding Y axis Title

    I believe this page will answer your question. Your code is from a macro recorder, which is not foolproof.

    Try adding this line of code after you set the axis:
    Please Login or Register  to view this content.
    I do not have a file set up to try this but your symptoms are exactly like the ones on that page.

  6. #6
    Registered User
    Join Date
    11-15-2011
    Location
    St. Louis, MO
    MS-Off Ver
    Excel 2013
    Posts
    69

    Re: Problem adding Y axis Title

    6StringJazzer, I placed that line at the top of my macro. When I stepped through that line in my macro, the Y-axis text box appeared. So that does seem to be the issue. Since it worked for the primary Y axis, I applied a similar line for the Secondary Y axis, and it also worked. I thought it would also work for the X axis, but when I tried to step through x-axis line:
    Please Login or Register  to view this content.
    it failed. I got an error on both lines. I tried them one at a time. I thought the syntax would be similar, but evidently neither one of these works for the x-axis. I wasn't if the x-axis could have a secondary axis or not. The error was:
    Run-Time error '-2147467259 (80004005)': Method 'Axes' of object '_Chart' failed

    I would have thought that the syntax would be similar.
    Steve

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Problem adding Y axis Title

    XlCategory is spelled wrong in both places the code you just posted.

    Also I think this should go after the SetElement code, rather than at the top, but I could be mistaken.

  8. #8
    Registered User
    Join Date
    11-15-2011
    Location
    St. Louis, MO
    MS-Off Ver
    Excel 2013
    Posts
    69

    Re: Problem adding Y axis Title

    6StringJazzer, Thank you so much. Steve

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 10-08-2014, 06:36 PM
  2. Secondary Y axis title and format problem
    By oro77 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 02-28-2012, 05:24 AM
  3. graphs - adding axis and title
    By Velvet in forum Excel General
    Replies: 1
    Last Post: 07-19-2006, 11:25 AM
  4. [SOLVED] I have a problem to properly display the title of Value (Y) axis i
    By Oak in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-05-2006, 12:20 PM
  5. chart y-axis title problem
    By C.Woulds in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 09-09-2005, 09:05 PM
  6. [SOLVED] Adding data on Axis Major Gridlines next to Category Axis Collums
    By jblittlejohn in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 07-10-2005, 08:05 AM
  7. Pasting Objects into Chart title and Axis title
    By Sam in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 06-06-2005, 04:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1