Skip to main content

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


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:

Best Office Productivity Tools

Supports Office/Excel 2007-2021 and 365  |  Available in 44 Languages  |  Easy to Uninstall Completely

Popular Features: Find/Highlight/Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns     Move Columns   |   Unhide Columns   |   Compare Columns to Select Same & Different Cells ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need Is Just A Click Away...

Supercharge Your Excel Skills: Experience Efficiency Like Never Before with Kutools for Excel  (Full-Featured 30-Day Free Trial)

kte tab 201905

60-Day Unconditional Money-Back GuaranteeRead More... Free Download... Purchase... 

Office Tab Brings Tabbed interface to Office, and 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! (Full-Featured 30-Day Free Trial)
60-Day Unconditional Money-Back GuaranteeRead More... Free Download... Purchase... 
 
Comments (5)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
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!
This comment was minimized by the moderator on the site
Take the code from above:

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

And modify it like so:

Selection.ShapeRange.Rotation = ActiveSheet.Range("A1").Value
This comment was minimized by the moderator on the site
Hey there, I have the same requirement too. Have you by chance figured out how to have the image rotate from "zero" every time?
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
Take the code from above:

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

And modify it like so:

Selection.ShapeRange.Rotation = ActiveSheet.Range("A1").Value
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations