Arrow pointer compass type

rintelen

Board Regular
Joined
Jul 30, 2006
Messages
96
Hi

I want to rotate an arrow image to exactly a value entered in a cell (dropdown of values between 0 and 180)

e.g. if the value is 0 it should point south, if East or West 90+ or - and if pointing North 180. Also all value between these e.g. 45 for South East or South West etc.

I need some VBA I guess to do this but I don't know how.

When the arrow has stopped, I need the macro to end cleanly so that the user can input other values.

Is this even possible?
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
yep its possible.
follow these steps

1. Add a shape to your worksheet and name it "Picture 1"
2. Format Shape and add a photo as background ( in your case it would be good if the picture was a square size )
3. Right click on SHEET1 Tab and VIEW CODE
4. Paste this code

Code:
Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

     On Error Resume Next
     If Target.Address = "$A$1" Then
          Dim angle As Integer
          ' set cell to get the angle from
          angle = CInt(ActiveSheet.Range("A1").Value)
          Call rotatePic(angle)
     End If
End Sub


Sub rotatePic(var As Integer)
     ActiveSheet.Shapes("Picture 1").Select
     Selection.ShapeRange.IncrementRotation var
End Sub


enter your angle into A1 , shape should rotate

obviously you can now edit this adding iF or case statements to rotate the way you want, hope this helps
 
Last edited by a moderator:
Upvote 0
Excellent, but what I need is to control this using a slider, and someway to reset the values so that it operates as follows:

Each time the slider is touched it starts again from due south (0) and moves up to a maximum of 180 degrees either clockwise (Westerly) or Anticlockwise (easterly). In other words the slider if slide from a middle position of zero, goes left, pointer moves west and if slid right pointer moves east - all the way to north depending on the inputs. 180 being vertical.

I'm not very good at VBA so not sure if this is possible.

How would I do that?
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top