Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Drawing object references

What I'm trying to do is have a macro that draws an arrow
from one cell to another. The first time I run the macro
it would need to draw the arrow from B26 to B33, the next
time it might be C21 to B23. The cells it will be drawing
from and to are going to be changing every time the macro
is written. Any help with this is appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Drawing object references

Jason,

Try something like the following:


Dim SH As Shape
Dim WS As Worksheet
Set WS = ActiveSheet
Dim StartCell As Range
Dim EndCell As Range

WS.Shapes.SelectAll
Selection.Delete

Set StartCell = Range("B6")
Set EndCell = Range("B33")

Set SH = WS.Shapes.AddLine( _
beginx:=StartCell.Left + StartCell.Width / 2, _
beginy:=StartCell.Top + StartCell.Height / 2, _
endx:=EndCell.Left + EndCell.Width / 2, _
endy:=EndCell.Top + EndCell.Height / 2)

With SH.Line
.EndArrowheadStyle = msoArrowheadTriangle
.EndArrowheadLength = msoArrowheadLengthMedium
.EndArrowheadWidth = msoArrowheadWidthMedium
.ForeColor.RGB = RGB(255, 0, 0)
End With


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com


"JASon" wrote in message
...
What I'm trying to do is have a macro that draws an arrow
from one cell to another. The first time I run the macro
it would need to draw the arrow from B26 to B33, the next
time it might be C21 to B23. The cells it will be drawing
from and to are going to be changing every time the macro
is written. Any help with this is appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Drawing object references

Exactly what I was looking for. Thanks Chip!

-----Original Message-----
Jason,

Try something like the following:


Dim SH As Shape
Dim WS As Worksheet
Set WS = ActiveSheet
Dim StartCell As Range
Dim EndCell As Range

WS.Shapes.SelectAll
Selection.Delete

Set StartCell = Range("B6")
Set EndCell = Range("B33")

Set SH = WS.Shapes.AddLine( _
beginx:=StartCell.Left + StartCell.Width / 2, _
beginy:=StartCell.Top + StartCell.Height / 2, _
endx:=EndCell.Left + EndCell.Width / 2, _
endy:=EndCell.Top + EndCell.Height / 2)

With SH.Line
.EndArrowheadStyle = msoArrowheadTriangle
.EndArrowheadLength = msoArrowheadLengthMedium
.EndArrowheadWidth = msoArrowheadWidthMedium
.ForeColor.RGB = RGB(255, 0, 0)
End With


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com


"JASon" wrote in message
...
What I'm trying to do is have a macro that draws an

arrow
from one cell to another. The first time I run the

macro
it would need to draw the arrow from B26 to B33, the

next
time it might be C21 to B23. The cells it will be

drawing
from and to are going to be changing every time the

macro
is written. Any help with this is appreciated.



.

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
Record a macro will not edit composite drawing object Walter Briscoe New Users to Excel 4 January 12th 09 10:49 PM
Position drawing object relative to cell Horatio J. Bilge, Jr. Excel Discussion (Misc queries) 2 September 29th 08 09:16 PM
Saving from Excel to MS Office Drawing Object sir23 Excel Discussion (Misc queries) 4 February 19th 08 02:53 AM
how do i copy and inserted drawing object in a cell to multiple ce BROCK8292 Excel Discussion (Misc queries) 1 February 20th 07 09:11 PM
Automatically moving a drawing object in a chart Dan k Charts and Charting in Excel 1 February 7th 06 03:06 AM


All times are GMT +1. The time now is 05:26 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"