Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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: 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 - |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Sep 12, 10:54*pm, Subodh wrote:
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 - Check the online help for AddShape. This should list all of the shape types (i.e. the other ones besides msoShapeParallelogram), of which line and triangle should be examples. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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(msoShapeIsoscelesTrian gle, 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 - |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I'm not sure I understand your question. if you want to delete the previous shape so they don't overlap. Just add this line "With ActiveSheet.Arcs.Delete End With " like sample below. Sub DrawArc() With ActiveSheet.Arcs.Delete End With With ActiveSheet.Arcs.Add(Range("D1"), Range("E1"), 200, 200) With .Border .LineStyle = xlContinuous .Weight = xlThin End With End With End Sub HTH Cimjet "Subodh" wrote in message ... 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(msoShapeIsoscelesTrian gle, 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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Is there a way to draw a vertical line from a point on the chart line to the bottom of the chart | Excel Programming | |||
Excel2007 - draw a line | Excel Discussion (Misc queries) | |||
draw a line | Excel Discussion (Misc queries) | |||
How do I draw a line of best fit? | Charts and Charting in Excel | |||
How do I draw a line of best fit? | Charts and Charting in Excel |