# Rotate based on shape name

#### BMeyer33

##### New Member
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
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
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
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
That is not what you asked for in post #1

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

#### BMeyer33

##### New Member
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
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
thanks for the feedback

Last edited:

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

### 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...