[Last Call] Learn how to a build a cloud-first strategyRegister Now


Excel Chart from VB

Posted on 2004-11-18
Medium Priority
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

EDDYKT earned 252 total points
ID: 12616451
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

mvidas earned 248 total points
ID: 12616529

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

ID: 12616597
You guys rock

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

829 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