Clockface and angles

hemsleysut

Board Regular
Joined
Jul 29, 2002
Messages
124
I'd like to design a clockface with an hour and minute hands and the user can move the hands and the angle between them is returned eg 3 o'clock would return 45degrees. Any ideas how to proceed.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

onlyadrafter

Well-known Member
Joined
Aug 19, 2003
Messages
5,703
Platform
  1. Windows
Hello,

Very interesting question.

Have got code working out the angle of two lines but I can't seem to get it above 90 degrees, will have a look on Moday as I am about to go home now.


Code:
Sub Macro4()
ActiveSheet.Shapes("Line 2").Select
HOR = Selection.ShapeRange.Item("Line 2").Width
VER = Selection.ShapeRange.Item("Line 2").Height
If HOR = 0 Then
    SECOND_ANGLE = 0
Else
If VER = 0 Then
    SECOND_ANGLE = 90
Else
    SECOND_ANGLE = Atn(VER / HOR) * 180 / 3.1415927
End If
End If

ActiveSheet.Shapes("Line 1").Select
H_VER = Selection.ShapeRange.Item("Line 1").Width
H_HOR = Selection.ShapeRange.Item("Line 1").Height
If H_HOR = 0 Then
    HOUR_ANGLE = 0
Else
If H_VER = 0 Then
    HOUR_ANGLE = 90
Else
    HOUR_ANGLE = Atn(VER / HOR) * 180 / 3.1415927
End If
End If
End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,095
Messages
5,768,054
Members
425,451
Latest member
JohnBrooksBiddle

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
Top