×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Creating a Chart in Excel using VBA

Creating a Chart in Excel using VBA

Creating a Chart in Excel using VBA

(OP)
I'm trying to create a pie chart in MS Excel 2000 using VB 6.  However, I need to do some computations on the data before sending it into the chart, and I can't create new fields on my worksheet to store the results.  So my problem is that as far as I can figure out, I can't use
ActiveChart.SetSourceData because that only takes a range, and my data is currently stored as a dictionary (although I could change that to a two dimensional array).  In VB, I found the MSChart control and it's ChartData Property, but I can't figure out how to make it work or begin to see how it'll work in Excel.  

Can anyone help me figure out how to show my values in a Pie Chart?  Thanks in advance...

Greg  

RE: Creating a Chart in Excel using VBA

I don't exactly know what the problem seems to be.. but sometimes you can get some nice insights by just recording the steps you would like to happen... and then generalize strip the code of the trash you don't need.

In my opinion it is possible to add data to the Excel worksheet and afterwards add the range to your graph.

Good luck!

RE: Creating a Chart in Excel using VBA

I would have thought you can still perform the computations in VBA, directing the results back to the worksheet, then have a predefined chart (of whatever type you want) to display the results.
You can assign a computation output value into a cell using a statement like :
Sheets("Sheetname").Range("A1").Value = ResultofCalculation

RE: Creating a Chart in Excel using VBA

(OP)
Well the thing is... by specification, I can't put data back onto the spreadsheet to use for the chart.  I had some success with the MSChart control, but have since been redirected to creating a PivotTable in VBA and creating a chart from that- only now I can't seem to get the VBA that creates the PivotTable to work, even when based on a recorded macro that did work.  

Thanks for your input...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close