Sei sulla pagina 1di 2

Create Macros in Excel

The purpose of macros is typical scheduling functions of Excel to facilitate the


execution of repetitive tasks. Creating a macro is similar to a tape recording,
the recording starts and takes place the desired task is automatically converte
d to code Visual Basic (VB). The task can be for example open a specific file re
sults, choose some columns and perform a certain type of graph. With the use of
the macro can repeat this set of tasks the number of times as necessary saving a
lot of time in case we are analyzing a large amount of results.
Install a Toolbar VisualBasic
[1] [2] [1] [2] [3] [4] [5]
[3] [4] [5]
Choose and run macros present to create new macros Open editor of Microsoft VB D
isplay the toolbox controls VB VB Edit controls inserted in the page for Excel
2 Recording the Macro
Click [2] to start recording a new macro.
You can name the macro and display a shortcut key that allows you automatically
run the macro as well as write some informative comments. Clicking OK starts the
process of recording the macro, ie all tasks that are carried forward from here
will be automatically converted into VB code. To end the macro recording just c
lick again in [2].
3 Run a Macro
Clicking appears on the screen the list of macros associated with the file. When
running takes place beginning the sequence of tasks that were previously record
ed.
Drawbacks The macro performs the tasks that were literally taped. Imagine for ex
ample that if you want to open a file called resultados.xls results with 3 colum
ns and 100 rows that is stored in C: \ results and make a graph of points with t
he column 1 and 3. For the macro to be successful when it is called, these condi
tions must be maintained, ie if the file has another name or is stored elsewhere
on the hard macro immediately gives an indication of error. It can still happen
the new results file have 200 lines in this case only the first 100 lines will
be graphics because this was the limit imposed on the implementation of macro or
even the third column is empty which will obviously generate a graph without po
ints. However all these inconvenient can be solved through simple programming of
the macro parameters such as the name and path to the file, or the limits for d
evelopment of graphics can be defined by the user via a programmable interface.
To access the programming environment you need to edit the macro as shown in the
next step
Edit Macro
Clicking on the Excel starts Editor Microsoft VB. This "program" is the working
environment that lets you view and change the code behind the macro. This code w
as generated automatically when we start recording the macro and reflects the ta
sks performed for the programming language VB.
The top window on the left shows the various elements of the project we are work
ing, in this case MacroTeste.xls. As you can see this project includes three Exc
el worksheets and a module may also include other elements which will be discuss
ed later. The module in question is open in the center window and not more than
one subroutine which were scheduled tasks performed by the macro. The window in
the lower left corner indicates the properties of each object modules, worksheet
s, checks, etc. and allows you to change the characteristics, or definitions of
each of these elements.

Potrebbero piacerti anche