MS Excel: How to use the COS Function (WS, VBA)
This Excel tutorial explains how to use the Excel COS function with syntax and examples.
Description
The Microsoft Excel COS function returns the cosine of an angle.
The COS function is a built-in function in Excel that is categorized as a Math/Trig Function. It can be used as a worksheet function (WS) and a VBA function (VBA) in Excel. As a worksheet function, the COS function can be entered as part of a formula in a cell of a worksheet. As a VBA function, you can use this function in macro code that is entered through the Microsoft Visual Basic Editor.
Syntax
The syntax for the COS function in Microsoft Excel is:
COS( number )
Parameters or Arguments
- number
- A numeric value used to calculate the cosine.
Returns
The COS function returns a numeric value.
Applies To
- Excel for Office 365, Excel 2019, Excel 2016, Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000
Type of Function
- Worksheet function (WS)
- VBA function (VBA)
Example (as Worksheet Function)
Let's look at some Excel COS function examples and explore how to use the COS function as a worksheet function in Microsoft Excel:
Based on the Excel spreadsheet above, the following COS examples would return:
=COS(A1) Result: 0.980066578 =COS(A2) Result: 0.939372713 =COS(A3) Result: -0.999964658 =COS(200) Result: 0.487187675
Example (as VBA Function)
The COS function can also be used in VBA code in Microsoft Excel.
Let's look at some Excel COS function examples and explore how to use the COS function in Excel VBA code:
Dim LNumber As Double LNumber = Cos(210)
In this example, the variable called LNumber would now contain the value of -0.883877473.
Advertisements