Solved

Rotate shape in XLS

Posted on 2014-03-28
5
426 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 49

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 49

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

929 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

15 Experts available now in Live!

Get 1:1 Help Now