Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Charts / VBA

Status
Not open for further replies.

wfn217

Chemical
Joined
Aug 11, 2006
Messages
101
Location
US
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?
 
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.
 
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.
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top