Excel Functions

Preview:

DESCRIPTION

Excel Functions. Part 1. Introduction. An Excel function is a formula or a procedure that is performed in the Visual Basic environment, outside the Excel spreadsheet. For example, the sum of two variables can be evaluated in an Excel spreadsheet as follows :. - PowerPoint PPT Presentation

Citation preview

Excel FunctionsExcel Functions

Part 1. Introduction

2

An Excel function is a formula or a procedure that is performed in the Visual Basic environment, outside the Excel spreadsheet.

3

For example, the sum of two variables can be evaluated in an Excel spreadsheet as follows:

4

Sum x + y

  x = 5

  Y = 3

Sum = 8

5

Sum of two variables in an Excel spreadsheet

This same sum can be done in the environment of Visual Basic (VB)

6

You can define a function called "Sum", which receives the You can define a function called "Sum", which receives the value of two inputs "x" and "y" and returns the value of value of two inputs "x" and "y" and returns the value of the sum of themthe sum of them

7

How to build the function "Sum"How to build the function "Sum"

8

- Click on the "Programmer" tab- Click on the "Programmer" tab

9

- Click on the "Programmer" tab- Click on the "Programmer" tab

10

If the tab is not available, see Note 1 "Activate tab" at the end of the document.

- Click on the "Programmer" tab- Click on the "Programmer" tab

11

Click on "view code"Click on "view code"

12

The "Visual Basic" ambient is openThe "Visual Basic" ambient is open

13

Function code

14

Function code

15

The codes are written in the VB "Modules"

Function code

16

The codes are written in the VB "Modules"

To open a module

Function code

17

The codes are written in the VB "Modules"

To open a module

Click right button on the left side window

Function code

18

The codes are written in the VB "Modules"

To open a module

Click right button on the left side window

It opens a window

19

Select “Insert”

Click Module

20

Appears the new created VB module, with the name Module1.

21

This name can be changed later by a more suitable one.

The right window displays a flashing line

22

The right window displays a flashing line

23

The module is now ready for use

Sum Function Code

24

Código de la función Suma

25

In the right window type the function name followed by the dependent variables.

Código de la función Suma

26

In the right window type the function name followed by the dependent variables

Function Suma(x,y)

Código de la función Suma

27

In the right window type the function name followed by the dependent variables.

Function Suma(x,y)

When you "Enter", VB automatically puts the final line of the function.

Sum Function Code

28

In the right window type the function name followed by the dependent variables.

Function Suma(x,y)

End Function

The new code must be written between these two commands.

29

The new code must be written between these two commands.

30

In this case, the code consists of a single line

The new code must be written between these two commands.

31

In this case, the code consists of a single line

Suma = x + y

32

The complete function looks like

 x = 5Y = 3

Sum =  =SUMA(C5,C6)Sum = 8

33

Application of the Sum function in the Excel spreadsheet

End of Part 1. Introduction

34

Activating the "Programmer" tab

35

Activating the "Programmer" tab

36

Nota 1

To activate the “Programmer” tab

1. Click the File tab.

2. Under Help, click Options.

3. Click Customize Ribbon.

4. Select the Developer check box.