# COS Excel Function

Published on :

21 Aug, 2024

Blog Author :

Wallstreetmojo Team

Edited by :

Ashish Kumar Srivastav

Reviewed by :

Dheeraj Vaidya

## COS Excel Function

COS Excel function is an inbuilt trigonometric function. It is used to calculate the cosine value of a given number or, in terms of trigonometry, the cosine value of a given angle. Here, the angle is a number in Excel. This function takes only a single argument which is the input number provided.

It is a built-in function in MS Excel. It is categorized under Math functions in MS Excel. The function returns the cosine of an angle given in radians. The parameter is the value of the angle for which the cosine is to be calculated. The angle can be calculated using the RADIANS function or multiplying by PI()/180.

##### Table of contents

- COS Excel Function
- COS Formula
- How to Use COS Function in Excel?
- Example #1 – Calculate the value of cos (0)
- Example #2 – Calculate the value of cos (30)
- Example #3 – Calculate the value of cos (45)
- Example #4 – Calculate the value of cos (60)
- Example# 5 – Calculate the value of cos (90)
- Things to remember about the COS Function in Excel
- Usage of COS function in Excel VBA
- Recommended Articles

### COS Formula

The COS Formula in Excel is as follows:

The COS formula in Excel has one argument, which is a required parameter.

**number**= This is a required parameter. It indicates the angle for which the cosine is to be calculated.

### How to Use COS Function in Excel?

The COS can be used in Excel worksheets as a Worksheet (WS) function and Excel VBA. As a WS function, it can be entered as a part of the COS formula in a worksheet cell. As a VBA function, it can be entered into the VBA code.

Refer to the examples given below to understand better.

### Example #1 – Calculate the value of cos (0)

In this example, cell B2 contains the value of the angle for which cosine is to be calculated. Cell C2 has a COS formula associated with it, which is RADIANS. COS in excel is assigned to cell D2. RADIANS(B2) is 0. Further, COS is applied to 0, which is 1.

Hence, the resultant cell D2 has a value of 1 as COS(0) is 1.

### Example #2 – Calculate the value of cos (30)

In this example, cell B3 contains the value of the angle for which cosine is to be calculated. Cell C3 has a COS formula associated with it, which is RADIANS. COS in excel is assigned to the D3 cell. RADIANS(B3) is 0.523598776. Further, COS is applied to 0.523598776, which is 0.866025404.

Hence, the resultant cell D3 has a value of 1 as COS (0.523598776) is 1.

### Example #3 – Calculate the value of cos (45)

In this example, cell B4 contains the value of the angle for which cosine is to be calculated. Cell C4 has a COS formula associated with it, which is RADIANS. COS is assigned to the D4 cell. RADIANS(B3) is 0.523598776. Further, COS is applied to 0.785398163, which is 0.707106781.

Hence, the resultant cell D4 has the value of 1 as COS (0.707106781) is 1.

### Example #4 – Calculate the value of cos (60)

In this example, cell B5 contains the value of the angle for which cosine is to be calculated. Cell C5 has a COS formula associated with it, which is RADIANS. COS is assigned to the D5 cell. RADIANS(B5) is 1.047197551. Further, COS is applied to 1.047197551, which is 0.5.

Hence, the resultant cell D5 has a value of 0.5 as COS (1.047197551) is 0.5.

### Example# 5 – Calculate the value of cos (90)

In this example, cell B6 contains the value of the angle for which cosine is to be calculated. Cell C6 has a COS formula associated with it, which is B6*PI ()/180. COS is assigned to the D6 cell. 90*PI ()/180 is 1.570796327**. **The value of PI () is 3.14159. So, it is 90 * (3.14159/180) =1.570796327. Further, COS is applied to 1.570796327, which is 6.12574E-17**.**

Hence, the resultant cell D6 has 6.12574E-17, as COS (1.570796327) is 6.12574E-17.

**Things to remember about the COS** **Function in Excel**

- The COS in Excel always expects radians as the parameter for which the cosine is calculated.
- If the angle is in degrees, it must be calculated using the RADIANS function or multiply the angle by PI ()/180.

**Usage of COS function in Excel VBA**

The COS in Excel can be used in Excel VBA as follows. First, it serves the same purpose: to get the cosine value of the angle provided.

Syntax: COS ( Number ) |

#### VBA Example #1

Dim val1 As Double val1 = Cos ( 0 ) val1 :1

Here, val1 is a variable. It is declared as Double, which indicates it can hold data with the double data type. The cosine of 0 is 1. Hence, val1 has value 1.

#### VBA Example# 2

Const pi = 3.1415 Dim val As Double'Convert 45 degrees to radians by multiplying by pi/180. val = Cos (45 * pi / 180 ) ' The variable val is now equal to 0.7071067

Here, angle 45 is converted to radians using the same COS formula in the Excel worksheet.

If a non-numeric value is provided to the Cos in Excel, it will return a

If a non-numeric value is provided to the Cos in excel then, it will return Type Mismatch error in Excel VBA code.

### Recommended Articles

This article has been a guide to COS Function in Excel. Here, we discuss the COS formula in Excel and how to use it, Excel examples, and downloadable Excel templates. You may also look at these useful functions in Excel: -