Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default rotate picture based on cell value

I have a picture (a compass arrow). I am trying to write a macro that will
rotate the image based on a value contained in a cell. Lets say the azimuth
is 87 degrees, then cell K9 would contain the value 87. I would like the
arrow to rotate by 87 deg, to visually reflect the azimuth.

So fare I am able to get the shape to rotate by a fixed value by using for
example

Selection.ShapeRange.IncrementRotation 87#

How do I have excel pick the value in cell K9 and rotate the object
accordingly?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default rotate picture based on cell value

Untested...

Selection.ShapeRange.IncrementRotation activesheet.range("k9").value



elwood wrote:

I have a picture (a compass arrow). I am trying to write a macro that will
rotate the image based on a value contained in a cell. Lets say the azimuth
is 87 degrees, then cell K9 would contain the value 87. I would like the
arrow to rotate by 87 deg, to visually reflect the azimuth.

So fare I am able to get the shape to rotate by a fixed value by using for
example

Selection.ShapeRange.IncrementRotation 87#

How do I have excel pick the value in cell K9 and rotate the object
accordingly?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default rotate picture based on cell value

great thanks - is there a function for absolute rotation? Lets say the image sits a 87 to start with and I want to rotate it back to 0 - Currently if i enter 0, obviously nothing happens, since the rotation is relative.

---
frmsrcurl: http://msgroups.net/microsoft.public...-on-cell-value
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default rotate picture based on cell value

I'd suggest you putting something in the Worksheet_SelectionChange procedure
to capture the value in the range of interest BEFORE you change it. Once
it's changed, you can recalculate the angle and set it. You will probably
need a public variable to do this.
--
HTH,

Barb Reinhardt



"elwood" wrote:

great thanks - is there a function for absolute rotation? Lets say the image sits a 87 to start with and I want to rotate it back to 0 - Currently if i enter 0, obviously nothing happens, since the rotation is relative.

---
frmsrcurl: http://msgroups.net/microsoft.public...-on-cell-value
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default rotate picture based on cell value

You very rarely need to select an object to work with it. By not selecting the
object, it should make the code easier to read, too.

Option Explicit
Sub testme()

Dim myShape As Shape

Set myShape = ActiveSheet.Shapes("Picture 1")

myShape.IncrementRotation 45

MsgBox "Hey, it's crooked!"

myShape.Rotation = 0

MsgBox "Back to normal!"

End Sub



elwood wrote:

great thanks - is there a function for absolute rotation? Lets say the image sits a 87 to start with and I want to rotate it back to 0 - Currently if i enter 0, obviously nothing happens, since the rotation is relative.

---
frmsrcurl: http://msgroups.net/microsoft.public...-on-cell-value


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default rotate picture based on cell value

that's exactly what i would do, if i had the slightest idea how.... ;)

---
frmsrcurl: http://msgroups.net/microsoft.public...-on-cell-value
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default rotate picture based on cell value

thanks again - makes a lot of sense. I have to admit, I know nothing about VB, so I just used the first example i could find that I half way understood and got to work....

---
frmsrcurl: http://msgroups.net/microsoft.public...-on-cell-value
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Picture based on cell value Jim Excel Worksheet Functions 3 July 24th 09 01:28 PM
Rotate a Picture CLR Excel Programming 6 April 19th 09 03:28 PM
If statement to add picture based on cell value Scott Excel Programming 1 June 19th 08 10:00 AM
How to add picture based on a cell value TUNGANA KURMA RAJU Excel Discussion (Misc queries) 3 October 31st 05 04:47 AM
How I do I rotate text in an excel cell? The rotate commands is g. MickG Excel Discussion (Misc queries) 3 December 13th 04 08:14 PM


All times are GMT +1. The time now is 07:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"