![]() |
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 |
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 |
All times are GMT +1. The time now is 03:31 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com