Inverse Sine calculation with formualr1c1 function

bradyj7

Board Regular
Joined
Mar 2, 2011
Messages
106
Hi there,

I want to find the inverse sine (sin^-1) of numbers in a column to get a column of angles next to it. I cant figure it out. This is what I have so far. The values are in the previous column.
Code:
    Range("m1").Value = "Angle of road"
    Range("m2").Value = 0
    Range("m3:m" & LastRow).FormulaR1C1 = "=Atn( rc[-1] / Sqr(rc[-1] * rc[-1] + 1))"

I got the inverse sine function from this page http://www.vbforums.com/showthread.php?t=161043

When I compile it, there is no error but this #NAME? is returned in the cells

Thank you
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,517
There is no ATN function. Are you trying to use ATAN? Same for SQR .... SQRT maybe?
 

bradyj7

Board Regular
Joined
Mar 2, 2011
Messages
106
To be honest I don't know what ATN is, I just took it form the link above. Would you know how to calculate the inverse sine of a number in vba.
 

bradyj7

Board Regular
Joined
Mar 2, 2011
Messages
106

ADVERTISEMENT

Do you mean this
Code:
Range("m1").Value = "Angle of road"
    Range("m2").Value = 0
    Range("m3:m" & LastRow).FormulaR1C1 = "=ASIN (rc[-1])"

I tried this but it just returns the value in the previous cell?

Thank you
 

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,517
What values are in your cells? Show the first few values in column M.
 

bradyj7

Board Regular
Joined
Mar 2, 2011
Messages
106

ADVERTISEMENT

What values are in your cells? Show the first few values in column M.

Hi,

They are all decimals, the first few values are 0.039999999, -0.023441861, 0.025200002, 0.022941175

Cheers
 

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,517
Your values are all very closr yo zero, that's what I'd expect as the results. See some more examples here:
Excel Workbook
AB
80.60.643501
9-0.823-0.96667
100.921.16808
110.951.253236
120.9951.470755
Sheet12


What exactly were you expecting for those values anyway?
 

bradyj7

Board Regular
Joined
Mar 2, 2011
Messages
106
Oh I think your right. I'm working in degrees not radians. So when I was doing sin-1(0.6) on my calculator (which is in degrees) was getting 36.87 degrees as the angle. But sin-1(0.6) in radians is 0.6435 as above. I just need to convert degrees to rads.

Cheers
 

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,881
Do you mean this
Code:
Range("m1").Value = "Angle of road"
    Range("m2").Value = 0
    Range("m3:m" & LastRow).FormulaR1C1 = "=ASIN (rc[-1])"

I tried this but it just returns the value in the previous cell?

Thank you

Hi bradyj7

Please notice that for very small values of x, sin(x) and asin(x) are approximately equal to x.

For ex., for your first value, if you are showing in the cell 3 decimals, asin(0,04) will display 0,04

If you try a bigger vakue, for ex. 0.4 you'll see the result 0.412. Here, since it's a bigger value you can already see the difference.

For the values you posted, {0.039999999, -0.023441861, 0.025200002, 0.022941175}, they are close to zero and so expect asin() to show a value close to the argument. If you are displaying 3 decimals you'll see no difference in the argument and the result of the function.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,469
Messages
5,596,313
Members
414,052
Latest member
Dual Showman

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