Excel Chart from VB

Posted on 2004-11-18
Last Modified: 2010-05-02
I have figured out how to create an Excel Chart from VB my problem is I want to change the Category (x) axis labels and I cannot find a property that corresponds to it here is how to do it manually

Right click on the chart
Go to Source Data
Then the Series Tab
Then  Category (x) axis labels
and just enter the values you want but what I need to know is how to do this from code

I just need to know how to do it from code
Thank you
Question by:cdthurman
    LVL 26

    Assisted Solution

    I use record from macro and get this
    Tools->Macro->Record the macro

    When you've finished, press Alt-F11 to see code

    ActiveChart.SeriesCollection(1).XValues = "={""abcdd""}"
    LVL 35

    Accepted Solution


    To take EDDYKT's answer one step further, if you want to take the values from a portion of your worksheet or reference the chart without using the activechart, you can use syntax like:

     Charts("Chart1").SeriesCollection(1).XValues = Sheets("Sheet1").Range("C2:C13")

    Also, instead of using the "={""abcdd""}" you could use

     ActiveChart.SeriesCollection(1).XValues = Array("abc", "def", "ghi")


    Author Comment

    You guys rock

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now