How do I draw lines..??

M

MIKEB

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:
 
T

Tom Ogilvy

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.
 
M

MIKEB

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.
 
B

Bob Kilmer

Cells have a Top and Left property that give their graphical location on a
worksheet.
 
T

Tom Ogilvy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top