VBA mathematical functions

Description of mathematical functions in Excel VBA

Below are the names and descriptions of all standard math functions in Excel VBA. As you can see functions such as RND () do not require arguments. Functions such as ROUND () require 2 arguments – the value and the number of decimal places to which we round our value. Numbers with decimal places in VBA are introduced usingdots “.”, not a comma, as it does in the Excel spreadsheet.



VBA mathematical functions – an example of use

It’s time to test our functions. Let’s create a simple program, introducing to the cells of our sheet the results of all mathematical functions.


Below, the use of trigonometric functions:



If you would like to use the VBA math functions in conjunction with the worksheet functions, I invite you to the next part of our VBA training. You will learn how to use any VBA function from the Excel spreadsheet using VBA.

Tasks (You can enter the solution in a comment)

  1. Replace the number 33.445 with an integer. Try to use three different functions for this purpose.
  2. For the number -21, perform the following actions in the VBA code, which you will display in the form of the MsgBox window: absolute value calculation, square root, and rounding to 3 decimal places. At the end, multiply the number by 5.
  3. For ambitious people: With the tangent function at their disposal, calculate the cotangent function with π / 4.




Leave a comment

Your email address will not be published. Required fields are marked *

One thought on “VBA mathematical functions”

%d bloggers like this: