+ Reply to Thread
Results 1 to 7 of 7

Set chart axis title within Macro

  1. #1
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Set chart axis title within Macro

    Hi
    I have worked out a rudimentary system to change data source for a template chart via macro buttons. When I use though I lose my Category(X)axis labels which should be set as a named range TITLES.

    I have tried umpteen inserts into code below but cannot hit on the one I need to always format the x axis labels.

    Ant assistance appreciated

    Rgds Nigel. Attached code used

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437
    You need to set the XValues of a series collection.

    So code more like this, changing the workbook name to suit.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    06-14-2008
    Posts
    153
    Try this:

    ActiveChart.SeriesCollection(1).XValues = Worksheets("Sheet1").Range("Titles")

    Change the name of the worksheet as applicable.

    It works fine in Excel 2003
    Welcome to: http://www.exceldigest.com/myblog/
    "Excel help for the rest of us"

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437
    Hi se1429,

    That will set the axis labels to the range defined by the named range Titles but it will be a static link.

    If the range Titles changes the chart will not update.

  5. #5
    Forum Contributor
    Join Date
    06-14-2008
    Posts
    153
    Hi

    I tried changing some cells within the range, and chart got updated on the spot.
    May be you have to setup some other chart properties. I am not sure. I hope I could give an immediate answer.

    Regards.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437
    Yes, if you change any of the existing cells in the range then yes the chart will update.

    I was thinking, maybe too much , that the range was dynamic, in that it could expand or contract.

  7. #7
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Perfect

    Many thanks Andy / Se1429

    I had nearly gotten there but forgot the "!" in the reference. Many thanks for your help. Finished article attached for reference. I have one more question to finish it completely but I will post that as a new question as the title of it will have to change.

    Many thanks again for all help

    Rgds Nigel
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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