Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Using Sine Cosine and Tan in Excel.

Using Sine Cosine and Tan in Excel.

Using Sine Cosine and Tan in Excel.

Can any one give me guidance in using Sine/Cosine/Tan in excel.

1000*Cosq and so on.

How do you write it in excel format?

RE: Using Sine Cosine and Tan in Excel.

- Place the value that you want to take the sin, cos, or tan, in cell A1.

- In cell B1 type "=1000 * sin(A1)".  For cos, use cos(A1).  For tan, use tan(A1).

RE: Using Sine Cosine and Tan in Excel.

Also, my excel uses radians (maybe there is a way to set the default to degrees?)

To convert degrees to radians, multiply by Pi/180

For example to find the cos of cell G20 which contains an angle in degrees, use the following:


Eng-tips forums: The best place on the web for engineering discussions.

RE: Using Sine Cosine and Tan in Excel.

You can also use degrees() and radians() to do the unit conversions, so sin(radians(90)) returns 1


RE: Using Sine Cosine and Tan in Excel.

There are a couple of worksheet functions that deal with the degrees - radians issue.

=RADIANS(C2) equals 4.71238898 radians when C2 = 270 degrees (3pi/2 radians)

=DEGREES(C6) equals 179.999848 degrees when C6 = 3.14159 radians


RE: Using Sine Cosine and Tan in Excel.

It would just be a lot easier if the darn programmers of excel would let you default to degrees like the calculators do.  This is always the pain in the tukus when dealing with trig functions in excel - or any spreadsheet that I've seen thus far.

RE: Using Sine Cosine and Tan in Excel.

I thought it would be extremely easy to write your own functions in VBA to use degrees as input. However, it looks like the BASIC trigonometric functions (sin, cos, tan) are missing in VBA for Excel, even though some of the more esoteric functions (sinh, cosh, etc) are supported!

I can’t get the following VBA Macro to work – it generates a "#VALUE!" error:

     Public Function sindeg(theta_degrees)
     End Function

However, the following macro (with just the addition of one character, to convert “sin” to “sinh”) runs fine. (It’s just a shame that it generates the wrong answer!)

     Public Function sindeg(theta_degrees)
     End Function

Does anyone know a way around this apparent fundamental limitation of VBA?

RE: Using Sine Cosine and Tan in Excel.

sin works fine in VBA on my puter


Greg Locock

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.

RE: Using Sine Cosine and Tan in Excel.


What version of Excel are you running?

I am beginning to suspect the omission of the basic trig functions (sin etc) in VBA is a new "enhancement" in the 2003 version. I have found plenty of references to using trig functions in VBA in older versions, but the examples won't run on my 2003 version.

For example, Microsoft on-line help defines "SIN" in the 1997 VBA reference here:


However, the 2003 on-line reference provides a list of mathematical functions available in VBA - see here:


The hyperbolic functions (SINH, COSH, etc) are listed, as are the inverse trig functions (ASIN, ACOS, etc), but the basic trig functions (sin, cos, tan) are conspicuous by their absence. Sure enough, I can run a VBA function which uses SINH, but when I try to use SIN, it generates an error message.

Surely I am missing something obvious?!?

RE: Using Sine Cosine and Tan in Excel.

'97. Good catch.


Greg Locock

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.

RE: Using Sine Cosine and Tan in Excel.

I have Excel 2003

In the worksheet, =sin(90) yields a correct answer

In VBA, Range("A1").Value = Sin(90) puts the correct value in cell A1

Perhaps you have to load the analysis pack in Excel?

RE: Using Sine Cosine and Tan in Excel.

OK – I think I have worked out the answer to my own question. (Thanks to GregLocock and IFRs!)

It seems there is a group of core mathematical functions which are built into the core of VBA. These functions include Sin, Cos, Tan, etc, and the correct syntax is the normal method of calling such a mathematical function:

     sindeg = Sin(theta_degrees / 180 * Pi)

(Note that the syntax for the VBA arc-tan function is Atn(x) NOT Atan(x), which is the Excel syntax.)

Then, you can access MOST (but not all) Excel mathematical functions using the following syntax:

     answer = Excel.WorksheetFunction.Sinh(x)

A list of Excel functions which are available in this way can be found by opening Visual Basic help, and then search down through the contents for:

    Microsoft Excel Visual Basic Reference
        Programming Concepts
            Events, Worksheet Functions & Shapes
                Using Microsoft Excel Worksheet functions in Visual Basic

and then click on the link to “List of Worksheet Functions Available to Visual Basic”. These available functions include the hyperbolic functions (Sinh, Cosh, etc), Acos, Asin, Atan2 (but NOT Atan!), and so on.

Note that it seems that in general, if any function is built into the core of VBA, the Excel version is NOT available in this way. That is:

     sindeg = Sin(theta_degrees / 180 * Pi)

will work, but

     sindeg = Excel.WorksheetFunction.Sin(theta_degrees / 180 * Pi)

will generate an error.

Sorry if this is obvious to others, but it caused me a LOT of grief working out where I went wrong.

For the record, the following VBA code runs fine. (Note – this is just a demonstration – I KNOW it’s not the most efficient way to achieve my objectives! Note also, I have used the excel Function Pi() to create a local variable called Pi. This is probably very poor programming form, but is allowable here, because VBA does not seem to recognise Pi as a reserved keyword, unless it is in the Excel.WorksheetFunction.Pi() syntax.)

     Public Function sindeg(theta_degrees)
          Pi = Excel.WorksheetFunction.Pi()
          sindeg = Sin(theta_degrees / 180 * Pi)
     End Function

RE: Using Sine Cosine and Tan in Excel.

To avoid rounding errors, I have resorted to using degrees for input and result output, and letting Excel do all the intermediate calcs in 'native' radians mode.

Life is non-linear...

RE: Using Sine Cosine and Tan in Excel.

Great info Julian.  I was about to give you a star and I noticed an ironic twist....

The only post with a star in this thread is a post which was a passing comment by it's nature no constructive info intended or included

I had to pause to point out the irony before I deliver my star which will destroy the evidence.

Eng-tips forums: The best place on the web for engineering discussions.

RE: Using Sine Cosine and Tan in Excel.

Here is some more info:


Excel Trig Functions

SIN(30) equals -0.98803, the sine of 30 radians
SIN(RADIANS(30)) equals 0.5, the sine of 30°
Example: =SIN(RADIANS(30))

COS(1.5) equals 0.07074, the cosine of 1.5 radians
COS(RADIANS(1.5)) equals 0.99966, the sine of 1.5°
Example: =COS(RADIANS(1.5))

TAN(2) equals -2.18504, the tangent of 2 radians
TAN(RADIANS(2)) equals 0.03492, the tangent of 2°
Example: =TAN(RADIANS(2))

ASIN(0.5) equals 0.523599 radians
DEGREES(ASIN(0.5)) equals 30°, the arcsine of 0.5
Example: =DEGREES(ASIN(0.5))

ACOS(-0.5) equals 2.09440 radians
DEGREES(ACOS(-0.5)) equals 120°, the arccosine of -0.5
Example: =DEGREES(ACOS(-0.5))

ATAN(1) equals 0.785398 radians
DEGREES(ATAN(1)) equals 45°, the arctangent of 1
Example: =DEGREES(ATAN(1))


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close