asked on # How do I change the angles of an existing triangle by entering different values in 3 cells?

That's pretty much it. I know I can move the apex of a triangle with this code, the position of the apex determined by the value in [O2] with this code:

How do I write that?

Thanks!

John

```
ActiveSheet.Shapes.Range(Array("My Triangle")).Adjustments.Item(1) = [O2]
```

But I would like some code that keeps the apex at zero and sets the apex angle to 60 degrees.How do I write that?

Thanks!

John

Microsoft ExcelVBA

Excel isn't a drawing program so I believe the answer is that you can't do it with Excel's triangle shapes since the right triangle shape always has to have one angle of 90 degrees and the isosceles shape needs to have two equal length sides and two equal angles. You might be able to do it with three lines that represent the sides of the triangle but you'd probably need some of the functions of some math library.

Hi Martin, I have a code that will calculate the angles of a right triangle if I know the height and width of the triangle. I'm just curious about doing it in reverse and calculating the height and width based on the apex angle. here's the code I'm using to find the angles of a given triangle. Do you see a way to adapt it to work in reverse?

Thanks,

John

```
Sub HypAndAngle()
ActiveSheet.Shapes(Application.Caller).Select
Dim x, y, hyp, angle As Double
Const Pi = 3.1415926 'defines constant for pi
x = Selection.ShapeRange.Height
y = Selection.ShapeRange.Width
hyp = Round(Sqr(x ^ 2 + y ^ 2), 2) 'calculate hypotenuse
angle = Round(Atn(y / x) * 180 / Pi, 2) 'round angle to 2 decimals
[A5] = x
[B5] = y
[B6].Value = hyp
[B7].Value = angle
[B8] = 90 - angle
[A2].Select
End Sub
```

Thanks,

John

View this solution by signing up for a free trial.

Members can start a 7-Day free trial and enjoy unlimited access to the platform.

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.