Excel FunctionsExcel Functions
Part 1. Introduction
2
An Excel function is a formula or a procedure that isperformed in the Visual Basic environment, outside the Excelspreadsheet.
3
For example, the sum of two variables can be evaluated in anExcel spreadsheet as follows:
4
z
x + y
 
x =
5
 
y =
3
z =
8
5
Sum of two variables in an Excel spreadsheet
This same sum can be done in the environment ofVisual Basic (VB)
6
You can define function called "Sum", which receives thevalue of two inputs "x" and "y" and   returns the value ofthe sum of themYou can define function called "Sum", which receives thevalue of two inputs "x" and "y" and   returns the value ofthe sum of them
7
How to build the function "Sum"How to build the function "Sum"
8
Enter in Excel and in the main menuclick in the Developer tab.Enter in Excel and in the main menuclick in the Developer tab.
9
10
If this tab is not available, see Note 1 "Activate tab" atthe end of the document.
Click on "view code"Click on "view code"
11
The "Visual Basic" ambient is openThe "Visual Basic" ambient is open
12
Function code
13
Function code
14
The codes are written in the  VB "Modules"
Function code
15
The codes are written in the  VB "Modules"
To open a module
Function code
16
The codes are written in the  VB "Modules"
To open a module
Click right button on the left side window
17
Function code
18
The codes are writen 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
The right window displays a flashing line
21
Sum Function Code
22
Sum Function Code
23
In the right window type the function name followed bythe dependent variables in parentheses, separated by acomma.
Sum Function Code
24
In the right window type the function name followed bythe dependent variables in parentheses, separated by acomma.
Function Suma(x,y)
Sum Function Code
25
In the right window type the function name followed bythe dependent variables in parentheses, separated by acomma.
Function Suma(x,y)
When you press "Enter", VB automatically putsthe final line of the function.
Sum Function Code
26
In the right window type the function name followed bythe dependent variables in parentheses, separated by acomma.
Function Suma(x,y)
End Function
The new code must be writen between these two commands.
27
The new code must be writen between these two commands.
28
In this case, the code consists of a single line
The new code must be writen between these two commands.
29
In this case, the code consists of a single line
Suma = x + y
30
The complete function looks like
31
Application of the Sum function in the Excelspreadsheet
Type the values of x and y,
for example, in the cells
C5 and C6.
Type  =SUM(C5,C&) in acell and press enter.
32
Application of the Sum function in the Excelspreadsheet
The result valueappears in the cell
End of Part 1. Introduction
33
Activating the "Programmer" tab
34
Activating the “Developer" tab
35
Note 1
To activate the “Developer” tab
1.Click Options.
2.Click Customize Ribbon.
3. Choose commands from: All Tabs.
4. Select the Developer check box.
5. Click on Add
6. Activate, by clicking on Developer
7. OK