Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Modified ACOS function
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)))+D EGREES(ACOS(A2/(A2^2+B2^2)^0.5)),360)" End Sub |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Modified ACOS function
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 |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Modified ACOS function
It isn't entirely clear what your formula is trying to do. From 0 to 180
degrees it seems to convert your X and Y into an angle in the correct quadrant, but beyond 180 degrees it is doing something very different. I wonder whether =MOD(DEGREES(ATAN2(A2,B2)),360) might be what you are trying to achieve? -- David Biddulph "danpt" wrote in message ... 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)))+D EGREES(ACOS(A2/(A2^2+B2^2)^0.5)),360)" End Sub |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Modified ACOS function
Thank you Chip,
Thank you David, I overlooked my formulation, cell(D2) should look like =IF(B2<0,360-DEGREES(ACOS(A2/(A2^2+B2^2)^0.5)),DEGREES(ACOS(A2/(A2^2+B2^2)^0.5))) "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)))+D EGREES(ACOS(A2/(A2^2+B2^2)^0.5)),360)" End Sub |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Modified ACOS function
That looks a lot better, and gives the same result as the much simpler ATAN2
formula which I suggested. -- David Biddulph "danpt" wrote in message ... Thank you Chip, Thank you David, I overlooked my formulation, cell(D2) should look like =IF(B2<0,360-DEGREES(ACOS(A2/(A2^2+B2^2)^0.5)),DEGREES(ACOS(A2/(A2^2+B2^2)^0.5))) "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)))+D EGREES(ACOS(A2/(A2^2+B2^2)^0.5)),360)" End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
"last modified" timestamp function in excel 2003 | New Users to Excel | |||
modified CEILING function?? | Excel Worksheet Functions | |||
Modified Average Function | Excel Worksheet Functions | |||
Date Last Modified Function | Excel Worksheet Functions | |||
RANK Function Modified? | Excel Worksheet Functions |