Draw line of defined length
On Sep 13, 12:14*pm, "Cimjet" wrote:
Hi
Check this out.. just play with the numbers to change the arc and length
Sub DrawArc()
* * With ActiveSheet.Arcs.Add(10, 10, 200, 200)
* * * * With .Border
* * * * * * .LineStyle = xlContinuous
* * * * * * .Weight = xlThin
* * * * End With
* * End With
End Sub
===========
Triangle with all the bells and whistle, this one adjustable with size set in
cells E3 and *E4
Sub Make_Triangles()
* * Height_size = Range("E3").Value
* * Width_size = Range("E4").Value
* * *ActiveSheet.Shapes.AddShape(msoShapeIsoscelesTria ngle, 0, 200#, Width_size,
Height_size).Select
* * * *Selection.ShapeRange.Fill.Visible = msoTrue
* * Selection.ShapeRange.Fill.Solid
* * Selection.ShapeRange.Fill.ForeColor.RGB = RGB(180, 180, 120)
* * Selection.ShapeRange.Fill.Transparency = 0#
* * Selection.ShapeRange.Line.Weight = 0.75
* * Selection.ShapeRange.Line.DashStyle = msoLineSolid
* * Selection.ShapeRange.Line.Style = msoLineSingle
* * Selection.ShapeRange.Line.Transparency = 0#
* * Selection.ShapeRange.Line.Visible = msoTrue
* * Selection.ShapeRange.Line.ForeColor.RGB = RGB(10, 10, 10)
* * Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
* *Selection.ShapeRange.Fill.PresetTextured msoTextureWhiteMarble
End Sub
========
Different type of triangle, just change the line in the script above.
ActiveSheet.Shapes.AddShape(msoShapeRightTriangle, 0, 300#, Width_size,
Height_size).Select
================
HTH
Cimjet
"Subodh" wrote in message
...
On Sep 12, 5:17 pm, lifescholar wrote:
On Sep 12, 12:44 am, Subodh wrote:
Hi,
I want to draw a line of length equal to value of any
cell value.
For example, if the cell value is 10 its length should be 10 units and
it should
be changed to 15 if the cell value is 15.
Further, if possible, I would like to fix the point for the start of
the line (ie from where the line
will start). This is because I want to draw a quadrilater , say a
polygon with four sides,
two should be parallel to each other and the other should be inclined..
We have the lengths
for all the sides. So, when we change the dimensions of the lines they
should change
and still the polygon should be closed.
Any help in this will be appreciated.
Thanks in advance.
Why not use the parallelogram shape in Excel, rather than trying to
draw the shape with lines? Something like:
Thanks.
THis works.
What about if i need to draw just a line (not straight but inclined)
or a triangle ? Is there any way around for that ??
Sub Parallelogram()
ActiveSheet.Shapes.AddShape(msoShapeParallelogram, 420.75, 76.5,
177.75, 104.25).Select
Selection.ShapeRange.Fill.Visible = msoFalse
End Sub
The numbers are for (in order) the Left and Top positions on the
sheet, then the Width and Height of the shape, which could be pulled
from a cell, in which case you would substitute the values as follows:
Range("A1").Value- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
This is working fine. But when i try to get the line or any shape, I
have made trial to update
the shape each time the value changes.
But, the problem is that the shape is there alwasy. So, I want the VBA
to remember the previous one
and delete it beofre drawing it. So, it doesn't override
Any suggestions.
|