PDA

View Full Version : Sleeper: Using vba variable to create data series for pi and bar graphs



jjpratt
06-14-2005, 06:55 AM
I am relitivly new to VBA. I have been working with VB 6.0 for some time. But am still getting used to the Excel object model. I have variables in VBA and need to create new data series on both pie charts and bar graphs. I need to create new series in VBA using variables, strat(0), strat(1),,,,, If you have any idea on the line of code needed for this please help.

Justin :banghead:

Bob Phillips
06-14-2005, 07:52 AM
I am relitivly new to VBA. I have been working with VB 6.0 for some time. But am still getting used to the Excel object model. I have variables in VBA and need to create new data series on both pie charts and bar graphs. I need to create new series in VBA using variables, strat(0), strat(1),,,,, If you have any idea on the line of code needed for this please help.

Why not just do it in Exel with the macro recorder turned on?

jjpratt
06-14-2005, 08:30 AM
I have to create about 80 different charts and it is just easier if I could just pass values to a sub that creates the pie and bar graphs. The code I have tried is:


co1.Chart.SeriesCollection.Add
Source:= strat(0)

This does not work, but I need to use the variables as my series.

Bob Phillips
06-14-2005, 09:38 AM
I have to create about 80 different charts and it is just easier if I could just pass values to a sub that creates the pie and bar graphs.

If you record one, that will give the basis and with your VB knowledge you should be able to make into a generic function.

BlueCactus
06-14-2005, 09:41 AM
There are quite severe limitations on using variables as source data. See:
http://www.vbaexpress.com/forum/showthread.php?t=3374