Solved

Rotate shape in XLS

Posted on 2014-03-28
5
437 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 51

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 51

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

710 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