Hello All.
I'm trying to write some code to rotate a line by an amount specified in a cell. Each time this amount changes I want the bottom of the line to remain fixed so the line acts rather like that on a speedometer etc. However, the line moves each time and I can't work out the logic or how the AddLine parameters work and am stumped as to how to achieve this.
Please could anyone help?
My code so far is below:
Code
Private Sub Worksheet_Change(ByVal Target As Range)
Dim sshape As Shape
If Target.Address = "$J$18" Then
For Each sshape In Sheet1.Shapes
sshape.Delete
Next
End If
Set sshape = Sheet1.Shapes.AddLine(220, 270, 220, 170) 'XYXY
With sshape
.Name = "Line 1"
.Line.EndArrowheadStyle = msoArrowheadTriangle
.Line.EndArrowheadLength = msoArrowheadLengthMedium
.Line.EndArrowheadWidth = msoArrowheadWidthMedium
'.Top = 1
'.Left = -148.5
.Height = 90
.Width = 1
.Rotation = Target
End With
End Sub
Display More