Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Rotate shape in XLS

Posted on 2014-03-28
5
Medium Priority
?
454 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 53

Accepted Solution

by:
Rgonzo1971 earned 1500 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 53

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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

783 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