Rotate based on shape name

BMeyer33

New Member
Joined
Aug 3, 2019
Messages
5
I want to change the code below so if the value

30 is entered into Sheet 1 A2 then “Group 1” will rotate to shape ‘Isosceles Triangle 30’
40 is entered into Sheet1 A2 then “Group 1” will rotate to shape ‘Isosceles Triangle 40’
50 is entered into Sheet 1 A2 then “Group 1” will rotate to shape ‘Isosceles Triangle 50’

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Shapes.Range(Array("Group 1")).Select
Selection.ShapeRange.Rotation = Range("A2").Value * 90
ActiveCell.Select
End Sub

Can you help?
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
welcome to the forum @BMeyer33

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Rot As Double
    If Target.Address(0, 0) = "A2" Then
        Select Case Target
            Case 30, 40, 50
                On Error Resume Next
                Me.Shapes("Isosceles Triangle " & Target).Select
                Rot = Selection.ShapeRange.Rotation
                Me.Shapes.Range(Array("Group 1")).Select
                Selection.ShapeRange.Rotation = Rot
                On Error GoTo 0
        End Select
        Target.Select
    End If
End Sub
 
Upvote 0
Thank you! Close but does not seem to be able to rotate directly to the shape.

Does anyone know if there a way to rotate to a cell? For example

30 is entered into Sheet 1 A2 then “Group 1” will rotate to cell D21
40 is entered into Sheet1 A2 then “Group 1” will rotate to shape E12
50 is entered into Sheet 1 A2 then “Group 1” will rotate to shape G15

Here is the code can you help me reference the cells above

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Rot As Double
    If Target.Address(0, 0) = "A2" Then
        Select Case Target
            Case 30
                On Error Resume Next


                'Reference cell here


                Rot = Selection.ShapeRange.Rotation
                Me.Shapes.Range(Array("Group 1")).Select
                Selection.ShapeRange.Rotation = Rot
                On Error GoTo 0

            Case 40
                On Error Resume Next
              
                'Reference cell here


                Rot = Selection.ShapeRange.Rotation
                Me.Shapes.Range(Array("Group 1")).Select
                Selection.ShapeRange.Rotation = Rot
                On Error GoTo 0

            Case 50

                On Error Resume Next
              
                'Reference cell here


                Rot = Selection.ShapeRange.Rotation
                Me.Shapes.Range(Array("Group 1")).Select
                Selection.ShapeRange.Rotation = Rot
                On Error GoTo 0


        End Select
        Target.Select
    End If
End Sub
 
Upvote 0
Part of my message posted funny i.e. "Group 1" as “Group 1” so I posted again.

Does anyone know if there a way to rotate to a cell? For example


30 is entered into Sheet 1 A2 then “Group 1” will rotate to cell D21
40 is entered into Sheet1 A2 then “Group 1” will rotate to shape E12
50 is entered into Sheet 1 A2 then “Group 1” will rotate to shape G15

Code:
[/COLOR][/COLOR]Private Sub Worksheet_Change(ByVal Target As Range)    Dim Rot As Double
    If Target.Address(0, 0) = "A2" Then
        Select Case Target
            Case 30
                On Error Resume Next




                'Reference cell here




                Rot = Selection.ShapeRange.Rotation
                Me.Shapes.Range(Array("Group 1")).Select
                Selection.ShapeRange.Rotation = Rot
                On Error GoTo 0


            Case 40
                On Error Resume Next
              
                'Reference cell here




                Rot = Selection.ShapeRange.Rotation
                Me.Shapes.Range(Array("Group 1")).Select
                Selection.ShapeRange.Rotation = Rot
                On Error GoTo 0


            Case 50


                On Error Resume Next
              
                'Reference cell here




                Rot = Selection.ShapeRange.Rotation
                Me.Shapes.Range(Array("Group 1")).Select
                Selection.ShapeRange.Rotation = Rot
                On Error GoTo 0




        End Select
        Target.Select
    End If

End Sub[COLOR=#333333][COLOR=#333333]
 
Upvote 0
That is not what you asked for in post #1 :confused:

Cells do not rotate. What does "rotate to a cell" mean ?
 
Upvote 0
Yes, you are correct, that is not what i asked for in post # 1, it seemed that maybe what I asked for was not possible, so maybe instead of rotating Group 1 towards a shape it could be rotated towards a cell. Sorry for any confusion I created, so I am wondering if that is possible
 
Upvote 0
Yongle, never mind, I understand now, you are correct. Is there a way that I mark your reply to my original post as solved?
 
Upvote 0
You already have done so.
thanks for the feedback
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,487
Messages
6,113,937
Members
448,534
Latest member
benefuexx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top