## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# 2.12. Exploring VBA's Built-in Functions

## Problem

You need to get familiar with VBA's built-in functions and use them in your code, but you're not sure where to begin.

## Solution

Check out the Visual Basic Language Reference in the VBA help guide. There's a section in the language reference entitled "Functions," which includes an alphabetically organized list of built-in functions. For your convenience, I've summarized some of the more commonly used functions for scientific and engineering calculations in Table 2-2.

Table 2-2. Some useful VBA fuctions

Function

Comment

`Abs(` `number` `)`

Returns the absolute value of the number argument. The data type returned is the same as that of the argument.

`Atn(` `number` `)`

Returns the arctangent of the number argument. The returned data type is a `Double`. The result is in radians from -π/2 to π/2.

`Cos(` `number` `)`

Returns the cosine of the number argument, which represents an angle in radians. The return type is a `Double` in the range from -1 to 1.

`Exp(` `number` `)`

Returns e raised to the `number` power. The return type is a `Double`.

`Int(` `number` `)`

Returns the integer part of `number`, where `number` is a decimal number. The return type is an `Integer`. `Int` essentially truncates the number. To round a number use the `Round` function.

`Log(` `number` `)`

Returns the natural logarithm (to base e) of `number`. The return type is a `Double`. To calculate the base 10 log of a number, use the expression `Log(number) / Log(10`).

`Round(` `number` `)`

Returns `number ...`

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required