Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Returning Position Points from the currently selected cell

Consider the following code that makes a short, horizontal line:

ActiveSheet.Shapes.AddLine(10, 10, 25, 10).Select

AddLine needs coordinates (position points) in order to make a line. Now
consider any currently selected cell (Excel). A selected cell makes a square
or rectangle or some 4-sided shape (polygon?). How to return the four
coordinates from the currently selected cell? I will then use those
coordinates to draw a line the exact with of the cell.

I'm trying to automate the drawing of a Gantt chart in Excel using lines.
Selecting a range of cells and drawing a line between the extremeties will be
helpful. I don't think I want to use a bar chart--I've seen some examples of
those. Thanks.

Troy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Returning Position Points from the currently selected cell

Troy,

Something like this?...
'-------------------------
'Adds a horizontal line thru the middle of D10:E20
Sub Test()
Dim shpLine As Excel.Shape
With Range("D10:E20")
Set shpLine = ActiveSheet.Shapes.AddLine(.Left, .Top + (.Height / 2), _
.Left + .Width, .Top + (.Height / 2))
End With
shpLine.Line.Weight = 1.5
Set shpLine = Nothing
End Sub
'---------------------------------------
Jim Cone
San Francisco, USA


"Keys1970" wrote in message
...
Consider the following code that makes a short, horizontal line:
ActiveSheet.Shapes.AddLine(10, 10, 25, 10).Select
AddLine needs coordinates (position points) in order to make a line. Now
consider any currently selected cell (Excel). A selected cell makes a square
or rectangle or some 4-sided shape (polygon?). How to return the four
coordinates from the currently selected cell? I will then use those
coordinates to draw a line the exact with of the cell.
I'm trying to automate the drawing of a Gantt chart in Excel using lines.
Selecting a range of cells and drawing a line between the extremeties will be
helpful. I don't think I want to use a bar chart--I've seen some examples of
those. Thanks.
Troy

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Returning Position Points from the currently selected cell

Thanks Jim, this is very helpful!

"Jim Cone" wrote:

Troy,

Something like this?...
'-------------------------
'Adds a horizontal line thru the middle of D10:E20
Sub Test()
Dim shpLine As Excel.Shape
With Range("D10:E20")
Set shpLine = ActiveSheet.Shapes.AddLine(.Left, .Top + (.Height / 2), _
.Left + .Width, .Top + (.Height / 2))
End With
shpLine.Line.Weight = 1.5
Set shpLine = Nothing
End Sub
'---------------------------------------
Jim Cone
San Francisco, USA


"Keys1970" wrote in message
...
Consider the following code that makes a short, horizontal line:
ActiveSheet.Shapes.AddLine(10, 10, 25, 10).Select
AddLine needs coordinates (position points) in order to make a line. Now
consider any currently selected cell (Excel). A selected cell makes a square
or rectangle or some 4-sided shape (polygon?). How to return the four
coordinates from the currently selected cell? I will then use those
coordinates to draw a line the exact with of the cell.
I'm trying to automate the drawing of a Gantt chart in Excel using lines.
Selecting a range of cells and drawing a line between the extremeties will be
helpful. I don't think I want to use a bar chart--I've seen some examples of
those. Thanks.
Troy


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
Varying selected cells returning value always to the same cell jk Excel Discussion (Misc queries) 3 November 18th 08 05:33 PM
Position DataLables on a pivot pie chart realative to their Points Aaron Charts and Charting in Excel 0 September 1st 07 07:12 PM
Position selected cell nobbyknownowt Setting up and Configuration of Excel 2 February 1st 07 08:00 AM
Default cursor/selected cell position after protecting Stilla Excel Worksheet Functions 0 December 8th 05 02:28 PM
Determining chart points at mouse position Steve Excel Programming 2 May 30th 04 03:46 AM


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