Solved

Rotate shape in XLS

Posted on 2014-03-28
5
422 Views
Last Modified: 2014-03-28
In Excel, I can rotate an image via the code below.    How do I modify the ActiveSheet VBA line in order to rotate a "shape" (e.g., arrow).    I tried the following lines but they don't seem to work:

ActiveSheet.Shape("BearingArrow").ShapeRange.Rotation = Target
ActiveSheet.Shapes("BearingArrow").ShapeRange.Rotation = Target

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Then
        ActiveSheet.Pictures("Picture 1").ShapeRange.Rotation = Target
    End If
End Sub

Open in new window

0
Comment
Question by:ExpExchHelp
  • 3
  • 2
5 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39961718
Hi,

pls try


Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Then
        IncrRotation = Target.Value - Selection.ShapeRange.Rotation
        ActiveSheet.Pictures("Picture 1").ShapeRange.IncrementRotation = IncrRotation
    End If
End Sub

Open in new window

Regards
0
 

Author Comment

by:ExpExchHelp
ID: 39961721
Rgonzo1971:

The picture rotation works great as is.   I need to figure out how to rotate shapes.

Lines below don't work:
ActiveSheet.Shape("BearingArrow").ShapeRange.Rotation = Target
ActiveSheet.Shapes("BearingArrow").ShapeRange.Rotation = Target

EEH
0
 

Author Comment

by:ExpExchHelp
ID: 39961754
Never mind... I found a solution.   See below.

Will award you the points anyways (for chiming in here).

EEH
0
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 39961768
Hi,

You maybe found

ActiveSheet.Shapes("BearingArrow").DrawingObject.ShapeRange.Rotation = 25

Open in new window

Regards
0
 

Author Comment

by:ExpExchHelp
ID: 39961829
Rgonzo1971:

Thx -- solution is slightly different.   However, I now realized that the shape is rotating on its won axis vs. on, e.g., start point.

Please see attached XLS for details.   Any ideas how to change the VBA to so arrow rotates (based on value 0-360 in cell A1) but rotates on red circle?

EEH
RotateArrow.xlsm
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now