The following code will do what you want:
Function DegreesToRadians(Degrees As Double) As Double
Const PI As Double = 3.14159265358979
DegreesToRadians = (Degrees / 360) * 2 * PI
End Function
Function RadiansToDegrees(Radians As Double) As Double
Const PI As Double = 3.14159265358979
RadiansToDegrees = 360 * Radians / (2 * PI)
End Function
Function Quadrant(Radians As Double) As Integer
Dim D As Double
D = RadiansToDegrees(Radians)
Select Case D
Case 0 To 90
Quadrant = 1
Case 91 To 180
Quadrant = 2
Case 181 To 270
Quadrant = 3
Case Else
Quadrant = 4
End Select
End Function
The DegreesToRadians function converts a number of degrees to its
radians equivalent. The RadiansToDegrees function converts radians to
degrees. The Quadrant function returns the quadrant (90 degrees
regions, starting at the X axis rotating counter-clockwise), of a
value in Radians.
If you want to compute the quadrant of a value in degrees with a
worksheet function, use
=VLOOKUP(B3,{0,1;90,2;180,3;270,4},2,TRUE)
where B3 is the value in degrees. Pay attention to the mix of commas
and semi-colons in the formula.
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
On Sun, 2 Nov 2008 12:49:01 -0800, danpt
wrote:
I want to modified ACOS function to display in degrees reflecting to its
quartrant.
Is there another simpler formula to replace then one I have in cell(D2)?
Sub worksample()
Range("A1") = "X"
Range("B1") = "Y"
Range("C1") = "deg"
Range("D1") = "mod. ACOS"
Range("A2") = -1
Range("B2") = -1
Range("C2") = "=DEGREES(ACOS(A2/(A2^2+B2^2)^0.5))"
Range("D2") =
"=MOD(IF(B2=0,360,IF(A20,270,IF(A2<0,90,180)))+ DEGREES(ACOS(A2/(A2^2+B2^2)^0.5)),360)"
End Sub