Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
chart manipulation
How can i draw a rectangle on a chart
I have an x y scatter chart and want to draw a rectangle from known x y co ordinates thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
chart manipulation
This should put the upper left corner of the rectangle at the specified X
and Y values. You can adjust it to position the rectangle from there. Sub AddRectangleToChart() Dim yAxis As Axis, xAxis As Axis Dim y1 As Single, x1 As Single Dim x, y, shp As Shape x = 2.19 y = 4.333 Set yAxis = ActiveChart.Axes(xlValue, xlPrimary) Set xAxis = ActiveChart.Axes(xlCategory, xlPrimary) y1 = yAxis.Top + yAxis.Height - ((y / (yAxis.MaximumScale - yAxis.MinimumScale)) * _ yAxis.Height) x1 = xAxis.Left + (x / (xAxis.MaximumScale - xAxis.MinimumScale)) * _ xAxis.Width Set shp = ActiveChart.Shapes.AddShape( _ Type:=msoShapeRectangle, _ Left:=x1, _ Top:=y1, _ Width:=99.67, _ Height:=70.08) shp.ZOrder msoBringToFrong End Sub -- Regards, Tom Ogilvy "judith" wrote in message ... How can i draw a rectangle on a chart I have an x y scatter chart and want to draw a rectangle from known x y co ordinates thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Value manipulation | Excel Discussion (Misc queries) | |||
For better Performance in VBA for Excel - Strings manipulation OR Objects manipulation | Excel Programming | |||
csv manipulation question | Excel Discussion (Misc queries) | |||
Bit manipulation | Excel Programming | |||
VBA String manipulation | Excel Programming |