Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default Connecting lines

If I have a range in excel that has angles in degrees in one column and
lengths in the next.
ANGLE LENGTH
90 5
225 6
90 5

How could i draw a line with segments that have those dimensions (assuming
north is up) (Those dimension should end up drawing something like a Z)

Thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Connecting lines

One way:

Public Sub DrawLines()
' cdConvToRads = Pi / 180
Const cdConvToRads As Double = 0.0174532925199433
Const cdScaleFactor As Double = 2
Dim rCell As Range
Dim dAngle As Double
Dim dLen As Double
Dim dStartX As Double
Dim dStartY As Double
Dim dEndX As Double
Dim dEndY As Double

dStartX = 100
dStartY = 100
With ActiveSheet
For Each rCell In Range(.Cells(2, 1), _
.Cells(.Rows.Count, 1).End(xlUp))
With rCell
dAngle = .Value * cdConvToRads
dLen = .Offset(0, 1).Value * cdScaleFactor
End With
dEndX = dStartX + dLen * Sin(dAngle)
dEndY = dStartY - dLen * Cos(dAngle)
.Shapes.AddLine dStartX, dStartY, dEndX, dEndY
dStartX = dEndX
dStartY = dEndY
Next rCell
End With
End Sub

In article ,
choice wrote:

If I have a range in excel that has angles in degrees in one column and
lengths in the next.
ANGLE LENGTH
90 5
225 6
90 5

How could i draw a line with segments that have those dimensions (assuming
north is up) (Those dimension should end up drawing something like a Z)

Thanks in advance

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
Connecting lines disappear Chris Excel Discussion (Misc queries) 0 July 28th 07 03:14 PM
Connecting to FTP ben Excel Programming 1 April 20th 06 05:12 PM
Leader Lines Connecting Chart to Box TOMB Excel Discussion (Misc queries) 1 May 7th 05 06:02 PM
Leader Lines Connecting Chart to Box TOMB Charts and Charting in Excel 1 May 7th 05 06:00 PM
Need Help Connecting To DB J.Adams Excel Programming 3 May 31st 04 06:34 PM


All times are GMT +1. The time now is 05:43 AM.

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

About Us

"It's about Microsoft Excel"