Hello amazing people of the VBA world, I'm slowly getting better at VBA and understanding it but i'm getting a bit stuck on this particular thing and unsure why it's not working.
I've been able to indirectly reference a cell with a shape name before in order to show/hide a given shape so i know the code i wrote works, however when I try to apply it to this particular bit of code it doesn't work.
The shape I want to move is called "rya1" and the cell location to move it to is located in "AH24". When I directly reference the shape name this code works perfectly:
I want the shape name (because it will change) in cell "AH25" and then for the VBA to pull the name from that cell and use that shape in the code - this is what I wrote but it wasn't working.
Anyone any ideas why please?
I've been able to indirectly reference a cell with a shape name before in order to show/hide a given shape so i know the code i wrote works, however when I try to apply it to this particular bit of code it doesn't work.
The shape I want to move is called "rya1" and the cell location to move it to is located in "AH24". When I directly reference the shape name this code works perfectly:
Code:
Sub reflectiona()
Dim sh As Worksheet, myPic As Shape
Set sh = Sheets("Reflections and rotations")
Set myPic = sh.Shapes("rya1")
With myPic
.Top = sh.Range(sh.Range("AH24").Value).Top
.Left = sh.Range(sh.Range("AH24").Value).Left
End With
End Sub
Code:
Sub reflectiona()
Dim sh As Worksheet, myPic As Shape
Set sh = Sheets("Reflections and rotations")
Set myPic = sh.Shapes.Range(sh.Range("AH25").Value)
With myPic
.Top = sh.Range(sh.Range("AH24").Value).Top
.Left = sh.Range(sh.Range("AH24").Value).Left
End With
End Sub