# Change Height of triangle to grid with user input.

I want to create a spreadsheet with a right angle triangle. I want to adjust the height of the triangle based on a user input.
The Point of the triangle will always be on 1-1. I want to adjust the height of the triangle up and down the scale on the right axis.
If you can point me to a resource happy to learn this myself or if you have a solution that would be great.
Triangle.xlsm
###### Who is Participating?

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.

EngineerCommented:
If it is just that then you would be much better off if you did this on a chart.

See attached. Change the value in C32
Triangle.xlsm
1

Experts Exchange Solution brought to you by

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

Author Commented:
Thanks Saqib that will work nicely.
0
Excel & VBA ExpertCommented:
You may try something like below. Assign the following code to a button or triangle itself so that when the button or triangle is clicked, it will ask the user to input the desired triangle height and the height of the triangle will be adjusted accordingly.

In the attached, I have assigned the code to the triangle itself, you can click the triangle to run the code.
``````Sub AdjustHeightOfTriangle()
Dim ws As Worksheet
Dim shp As Shape
Dim heightInput As Integer

Set ws = Sheets("Sheet1")
Set shp = ws.Shapes("Right Triangle 125")
heightInput = Int(Application.InputBox("Input the desired height of triangle.", "Triangle Height!", Type:=1))

If heightInput = 0 Then
MsgBox "Height cannot be 0.", vbExclamation
Exit Sub
ElseIf heightInput > 26 Then
MsgBox "Height cannot be greater than 26.", vbExclamation
Exit Sub
End If
shp.Height = 15
shp.Top = ws.Range("C27").Top
shp.ScaleHeight heightInput, msoFalse, msoScaleFromBottomRight
End Sub
``````
Triangle.xlsm
1
###### 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.