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
IT SSMAsked:
Who is Participating?
 
Saqib Husain, SyedConnect With a Mentor 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
 
IT SSMAuthor Commented:
Thanks Saqib that will work nicely.
0
 
Subodh Tiwari (Neeraj)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

Open in new window

Triangle.xlsm
1
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.