×
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

Jobs

Excel Charts / VBA

Excel Charts / VBA

Excel Charts / VBA

(OP)
I want to plot data on an Excel chart using VBA.  In Quickbasic there is a "Line" statement that can be used, e.g., Line (10,10)-(20,20).  Is there anything similar to this in VBA?

RE: Excel Charts / VBA

Do you want to manipulate a Chart (i.e. a graph plotting data from the worksheet), or draw Shapes?
First option you use the ChartObjects collection of the worksheet, second option you use the Shapes collection.

Cheers,
Joerd

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.

RE: Excel Charts / VBA

(OP)
joerd,

If I use ChartObjects with AddLine it says "object does not support this property or method".  I am trying to draw lines on a chart using coordinates generated in the Basic program and not in cells.

RE: Excel Charts / VBA

You need a little more. The ChartObject has a Shapes collection, like the worksheet:

CODE

Dim c As ChartObject, L As Shape
Set c = ActiveSheet.ChartObjects(1)
Set L = c.Chart.Shapes.AddLine(88., 211., 267., 246.)

Cheers,
Joerd

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.

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!


Resources