Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to rotate an image based on a cell value in Excel?

In Excel, we can rotate the image by dragging the mouse, but have you ever tried to rotate an image based on a cell value. For instance, the image will be rotated by 90 degrees if the cell value is 90 in Cell A1 as below screenshot shown.
doc rotate image by cell 1

Rotate an image based on cell value with macro code

Enable you to do smarter, faster and better

Kutools - the best office productivity tool brings 300 advanced features to Excel. Details... Download...

Office Tab - brings tabbed interface to Excel and Word, make your work much easier. Details...Download...


Rotate an image based on cell value with macro code


Only a macro code can help you to rotate an image based on a cell value in Excel.

1. Type a value into the Cell A1 you will rotate the image by, and then activate the image you want to rotate.

2. Press Alt + F11 keys to enable the Microsoft Visual Basic for Applications window, and click Insert > Module to insert a blank new Module. See Screenshot:
doc rotate image by cell 2

3. Paste below code to the Module script, then press F5 to run the code. See screenshot:

VBA: Rotate image by cell value

Sub RotateImage()
Selection.ShapeRange.IncrementRotation ActiveSheet.Range("A1").Value
End Sub

doc rotate image by cell 3
doc rotate image by cell 1

Note: in the code, A1 is the cell you want to rotate the image based on, you can change it as you need.


Relative Articles:



Excel Productivity Tools

Kutools for Excel - The Best Office Productivity Tool

  • Brings 300 powerful advanced features to Excel, enable you to do smarter, faster and better.
  • No longer need memorizing formulas and VBA codes, give your brain a rest from now on.
  • Become an Excel expert in 3 minutes, Complicated and repeated operations can be done in seconds, 
  • Reduce thousands of keyboard & mouse operations every day, say goodbye to occupational diseases now.
  • 110,000 highly effective people and 300+ world-renowned companies' choice.
  • 60-day full features free trial. 60-day money back guarantees. 2 years of free upgrade and support.

Office Tab - brings tabbed interface to Office, make your work much easier.

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Haley · 1 years ago
    This is what I want to do to an image, but I want it to rotate from the vertical position by however many degrees the cell states each time. However, say the cell says 30, it will rotate 30 degrees, but then if the cell value changes to 15, it will rotate 15 from the 30 position (45 from the vertical). I want it to rotate 15 from the vertical this time. Is there a way to do this?


    Thanks!
    • To post as a guest, your comment is unpublished.
      Andrew · 7 months ago
      Take the code from above:

      Selection.ShapeRange.IncrementRotation ActiveSheet.Range("A1").Value

      And modify it like so:

      Selection.ShapeRange.Rotation = ActiveSheet.Range("A1").Value
    • To post as a guest, your comment is unpublished.
      Jon H. · 1 years ago
      Hey there, I have the same requirement too. Have you by chance figured out how to have the image rotate from "zero" every time?
      • To post as a guest, your comment is unpublished.
        Sunny · 1 years ago
        Sorry I have no idea about this problem. You can place your prolem in out forum, maybe someone can help you solve it. https://www.extendoffice.com/forum.html
        • To post as a guest, your comment is unpublished.
          Andrew · 7 months ago
          Take the code from above:

          Selection.ShapeRange.IncrementRotation ActiveSheet.Range("A1").Value

          And modify it like so:

          Selection.ShapeRange.Rotation = ActiveSheet.Range("A1").Value