Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Value manipulation Vic Excel Discussion (Misc queries) 3 April 3rd 09 03:18 PM
For better Performance in VBA for Excel - Strings manipulation OR Objects manipulation vmegha Excel Programming 2 December 19th 05 12:14 AM
csv manipulation question fally Excel Discussion (Misc queries) 1 October 9th 05 12:58 PM
Bit manipulation Tony Excel Programming 8 March 15th 05 02:11 PM
VBA String manipulation Chip Pearson Excel Programming 0 March 4th 04 11:02 PM


All times are GMT +1. The time now is 10:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"