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?
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
4,695
Office Version
365
Platform
Windows
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
 

BMeyer33

New Member
Joined
Aug 3, 2019
Messages
5
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
 

BMeyer33

New Member
Joined
Aug 3, 2019
Messages
5
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]
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
4,695
Office Version
365
Platform
Windows
That is not what you asked for in post #1 :confused:

Cells do not rotate. What does "rotate to a cell" mean ?
 

BMeyer33

New Member
Joined
Aug 3, 2019
Messages
5
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
 

BMeyer33

New Member
Joined
Aug 3, 2019
Messages
5
Yongle, never mind, I understand now, you are correct. Is there a way that I mark your reply to my original post as solved?
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
4,695
Office Version
365
Platform
Windows
You already have done so.
thanks for the feedback
 
Last edited:

Forum statistics

Threads
1,082,305
Messages
5,364,401
Members
400,800
Latest member
germanpbv

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top