ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I draw lines..?? (https://www.excelbanter.com/excel-programming/280435-how-do-i-draw-lines.html)

MIKEB

How do I draw lines..??
 
Question is, how do I go about drawing lines in Excel with VBA? I want
to draw a line using the drawing tool, not Borders and Shading. Where
would I get more info on Drawing Objects. Any help would be greatly
appreciated.


:confused: :confused: :confused:



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


Tom Ogilvy

How do I draw lines..??
 
A good start would be to turn on the macro recorder (tools=Macro=Record a
New macro)

then draw you lines manually. Change things as you would want. Turn off
the macro recorder and look at the code.

This is a good start at looking at what attributes and methods were
employed.

--
Regards,
Tom Ogilvy

"MIKEB" wrote in message
...
Question is, how do I go about drawing lines in Excel with VBA? I want
to draw a line using the drawing tool, not Borders and Shading. Where
would I get more info on Drawing Objects. Any help would be greatly
appreciated.


:confused: :confused: :confused:



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/




MIKEB

How do I draw lines..??
 
Thank you....But I am looking for as way to draw line relative to a row
and column, even if the row and column are resized.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


Bob Kilmer

How do I draw lines..??
 
Cells have a Top and Left property that give their graphical location on a
worksheet.

"MIKEB" wrote in message
...
Thank you....But I am looking for as way to draw line relative to a row
and column, even if the row and column are resized.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/




Tom Ogilvy

How do I draw lines..??
 
Where's the disconnect?

I recorded ActiveSheet.Shapes.AddLine(261.75, 49.5, 307.5, 141#).Select

I figure out the width and height

? 307.5-261.75
45.75
? 141.0-49.5
91.5

Now I adjust the code relative to E9

Sub Macro3a()
Dim rng As Range
Set rng = Range("E9")
ActiveSheet.Shapes.AddLine rng.Left + 45.75, _
rng.Top + 91.5, rng.Left, rng.Top
End Sub

--
Regards,
Tom Ogilvy



MIKEB wrote in message
...
Thank you....But I am looking for as way to draw line relative to a row
and column, even if the row and column are resized.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/





All times are GMT +1. The time now is 08:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com