View Full Version : Use Macro choose a graph??


jtanium
11-05-2007, 01:05 AM
How can I use Macro for choose a graph ??,A graph are generate by MS Excel.

shades
11-05-2007, 06:03 AM
Howdy, and welcome to the board.

Are you wanting the dialog box to appear that shows the chart choices?


Sub Test()
Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("B1:E5")
End Sub

Now, if you want the whole list of possibilities, when you are in VBE and have this code (with Auto List Members checked in Tools > Options > Editor (Tab) ), then delete xlLine, and it will bring up the possible choices.

Another option, but far less satisfactory is to develop a UserForm with the chart choices. But there are so many choices, it would be more cumbersome, and frustrating for the user, and a lot more work for you.

jtanium
11-05-2007, 07:06 PM
Thanks so much.I' a beginner to use Macro.

This is a sheet that I need to make.Following picture.

http://www.thupload.com/files/ab374fe168a2c604846a18212725cf20/6.jpg

*column A is a ref of combobox and A1 is a sheet "A1"(In this sheet has one graph)

A2 is a sheet "A2"
A3 is a sheet "A3"
etc.

All sheets are have many of data to generate a graph.

shades
11-09-2007, 02:01 PM
Can you expand and include an example workbook with what you expect to see?

Are these charts pre-built? Or are you wanting to build them on the fly? Will the data source change size (i.e. more rows/columns)?

shades
11-09-2007, 02:06 PM
As I look at it, it would be better not to have worksheets named with cell references. It can be confusing. This might be able to be done without VBA. But I don't know enough to determine that yet.