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:
ActiveSheet.Shapes.Range(Array("My Triangle")).Adjustments.Item(1) = [O2]

Open in new window

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
LVL 1
John CarneyReliability Business Tools Analyst IIAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
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.
0
John CarneyReliability Business Tools Analyst IIAuthor Commented:
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?

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

Open in new window


Thanks,
John
0
ozoCommented:
x = [B6].Value * Cos([B7].Value*Pi/180)
y = [B6].Value * Sin([B7].Value*Pi/180)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.