Вы находитесь на странице: 1из 42

Chapter 5

MACROS

Prepared by
Board of Studies, ICAI

100hrs Information Technology Training

Board of Studies, ICAI

Section 1: MACROS
Learning Objectives
Learn about Macros Settings,
Recording and executing
Macros,
Deleting Macros

100hrs Information Technology Training

Board of Studies, ICAI

Macros
Simplify routine
tasks.
Use macros to
automate some
common functions in
your spreadsheets.
Easily record macros
and play them back
to do the same thing
multiple times.
100hrs Information Technology Training

Board of Studies, ICAI

Macros
A macro is a
piece of computer
code, that is
written for Excel,
using the Visual
Basic for
Applications
(VBA)
programming
language.

100hrs Information Technology Training

(Visual Basic Editor: An environment in which you


write new and edit existing Visual Basic for
Applications code and procedures.)

Board of Studies, ICAI

Macros
To automate
repetitive tasks, you
can quickly record a
macro. In Microsoft
Office Excel. You can
also create a macro
by using the Visual
Basic Editor in
Microsoft Visual Basic
to write your own
macro script, or to
copy all or part of a
macro to a new
macro.

100hrs Information Technology Training

After you create a macro, you can assign it


to an object (such as a toolbar button,
graphic, or control) so that you can run it by
clicking the object.

Board of Studies, ICAI

Enabling Developer Tab


1. Click on
Office
Button
2. Click on
Excel
Options
3. On Popular
Tab check
Show
Developer
tab in
Ribbon
100hrs Information Technology Training

Board of Studies, ICAI

Enabling Developer Tab

Once you are done with the


process you will have the
Developer Tab ready
100hrs Information Technology Training

Board of Studies, ICAI

Macros Settings
In order to view
or alter the Excel
Macro Security
Setting in Excel
2007 :
Select the office
button.

100hrs Information Technology Training

Board of Studies, ICAI

Macros Settings
From the very
bottom of this
drop-down menu,
select Excel
Options
Select the Trust
Center Option and
from within this,
click on the Trust
Center Settings...
button
From within the
Macro Settings
100hrs Information Technology Training

Board of Studies, ICAI

Macros Settings
Trusted Locations
Excel 2007 has
introduced trusted
locations, which are
directories on your
computer that Excel files
can be placed in, if you
want no Macro checks to
be carried out when the
file is opened. This
means that, if placed in
a trusted location, the
Macros in your Excel file
will be enabled,
regardless of the Macro
Security Setting.

100hrs Information Technology Training

Microsoft has defined some default


trusted locations, which include the
following locations on your computer
drive:
Board of Studies, ICAI

Macros Settings
Program Files\Microsoft
Office\Templates
Program Files\Microsoft
Office\Office12\Startup
Program Files\Microsoft
Office\Office12\Library
These locations are listed in the
Trusted Locations option setting
in your Excel Workbook, which
can be accessed by the
following steps:
Select the main menu (from the
Microsoft Excel Logo at the top
left of the workbook)
From the very bottom of this
drop-down menu, select Excel
Options
Select the Trust Center Option
and from within this, click on
the Trust Center Settings...
button
Select the Trusted Locations
100hrs
Information
option from
the leftTechnology
hand menuTraining

Board of Studies, ICAI

Recording Macros

1. Click Developer Tab


2. Click on Use Relative Reference
3. Click on Record Macro

100hrs Information Technology Training

Board of Studies, ICAI

Recording Macros
This will give user
a dialog box. Type
the macros name
(without using
any spaces). This
will give user a
dialog box. Type
macros name
(without using
any spaces)

100hrs Information Technology Training

Board of Studies, ICAI

Recording Macros
2. To assign a CTRL
combination shortcut
keyto run the macro,
in the Shortcut key
box, type any
lowercase letter or
uppercase letter that
you want to use.
3. To include a
description of the
macro, in the
Description box, type
the text that you
want.
4. Click OK to start
recording.
100hrs Information Technology Training

Board of Studies, ICAI

Macros File
Excel has two
other file formats
that store
macros:
1. XLSM files,
which are
macro enabled
workbooks, are
stored using
XML.
2. XLSB files,
which are
workbooks
stored in
100hrs Information Technology Training

Board of Studies, ICAI

Run a Macro
You can execute the
macro you just
recorded by either
clicking on the
Macro button on the
Developer Tab or by
pressing Alt F8

100hrs Information Technology Training

Board of Studies, ICAI

Run a Macro
To see what Excel
did behind the
scenes you can
either click on
Macros button on
Developer Tab and
select Edit or you
can press Alt F11

100hrs Information Technology Training

Board of Studies, ICAI

Delete Macro
Open the
workbook that
contains the
macro that you
want to delete.
1. On the
Developer tab,
in the Code
group, click
Macros.
2. In the Macros
in list, select This
Workbook
3. In the Macro
100hrs
Information
name
box, Technology
click Training

Board of Studies, ICAI

Excel Visual basic Editor


The easiest way to access the
Visual Basic Editor in Excel is to
press the key combination ALT-F11
(ie. press the ALT key, and while
this is pressed down, press F11).
You will be presented with the
Visual Basic Editor, similar to the
image below (note that your normal
Excel window will remain open
behind this window).
100hrs Information Technology Training

Board of Studies, ICAI

Section 2: Protecting
Worksheets
Learning Objectives
Learn about opening non Excel
files, importing text files,
Protecting worksheets and
protecting Worksheet elements.

100hrs Information Technology Training

Board of Studies, ICAI

Opening a non Excel File


The user can open
many different types
of files (Text file,
Lotus 123, Quattro
Pro, Works, or dBASE
files) in Excel. To
open a nonexcel file:

1. Click Office
Button >
Open.
2. In the Files of
type box select
the type of file
that has to be
opened or
select All

100hrs Information Technology Training

Board of Studies, ICAI

Opening a non Excel File


3. Locate the folder
in which the file
was saved.
4. Select the
filename and click
OK.
5. If the Text Import
Wizard dialog box
appears, select the
Delimited, and
click Next.
6. Mark other
delimiters until a
parsed data,
arranged in neat
columns appears
in the preview
window. Then click

100hrs Information Technology Training

Board of Studies, ICAI

Opening a non Excel File


7. Click the heading
in the Data
preview window
for the column to
be formatted. If
the column
contains numbers,
select the
General option in
the Column data
format section. If
the column
contains date,
then select the
Date option.
8. Click Finish and
the data gets
imported into the

100hrs Information Technology Training

Board of Studies, ICAI

Importing text files


There are two ways
to import data from
a text file by using
Microsoft Office
Excel:
You can open the
text file in Excel, or
you can import the
text file as an
external data range
(external data range: A range of data that is brought into a
worksheet but that originates outside of Excel, such as in a
database or text file. In Excel, you can format the data or
use it in calculations as you would any other data.).
100hrs Information Technology Training

Board of Studies, ICAI

Exporting text files


To export data from Excel
to a text file, use the Save
As command.
There are two commonly
used text file formats:
Delimited text files (.txt), in
which the TAB character
(ASCII character code 009)
usually separates each
field of text.
Comma separated values
text files (.csv), in which the
comma character (,)
usually separates each
field of text

100hrs Information Technology Training

Board of Studies, ICAI

Protecting Worksheet
If the workbook
contains
confidential
information, a
password can
be applied to
it. This will
allow only
users with the
password to
open and view
the workbook:
100hrs Information Technology Training

Board of Studies, ICAI

Protecting Worksheet

To protect a
workbook follow
the steps given
below:
Open the
workbook and
select Save As
from the Office
Button.
In the Save As
dialog box, click
the Tools button
to display the
dropdown menu,
and
choose General
100hrs Information Technology Training
Options.

Board of Studies, ICAI

Protecting Worksheet
Enter the
password in the
Password to
Open box.
To have a
separate
password for
editing the file,
enter the
password in the
Password to
Modify box.
Click OK.
In the Confirm
Password
100hrs
Information Technology Training

Board of Studies, ICAI

Protecting Worksheet
Click OK to
return to the
Save As
dialog box.
Specify a
filename and
path for the
file and click
Save.
If prompted,
click Yes to
replace the

100hrs Information Technology Training

Board of Studies, ICAI

Protecting Worksheet
Protecting a
Shared Workbook:
When a workbook is
shared by many
users, the Track
Changes feature (for
tracking edits from
the other users) can
be helpful. Excel also
enables users to
share a workbook
and track the
changes. When a
password is entered,
the tracked changes
cannot be removed.

100hrs Information Technology Training

Board of Studies, ICAI

Protecting Worksheet
To protect and
share a workbook
with tracked
changes,
Select Review >
Protect Workbook
and Share
Workbook option.

100hrs Information Technology Training

Board of Studies, ICAI

Protecting Worksheet
The Protect
Shared Workbook
dialog box
appears.
Check the
Sharing with
Track Changes
option, and enter
a password if
needed.
100hrs Information Technology Training

Board of Studies, ICAI

Protecting Worksheet
Elements
1. Select the
worksheet that
you want to
protect.
2. To unlock any
cells or ranges
that you want
other users to be
able to change,
do the following:

100hrs Information Technology Training

Board of Studies, ICAI

Protecting Worksheet
Elements
Select each cell or
range that you want to
unlock.
On the Home tab, in the
Cells group, click
Format, and then click
Format Cells.

3. On the Protection tab, clear the Locked


check box, and then click OK.
100hrs Information Technology Training

Board of Studies, ICAI

Protecting Worksheet
Elements
To hide any
formulas
that you don't want to
be visible, do the
following:
In the worksheet, select
the cells that contain the
formulas that you want
to hide.
On the Home tab, in the
Cells group, click
Format, and then click
Format Cells.
On the Protection tab,
select the Hidden check
box, and then click OK.
100hrs Information Technology Training

Board of Studies, ICAI

Use Shared Workbook to


You can
create
Collaborate
a shared
workbookand
place it on a
network
location where
several people
can edit the
contents
simultaneously

100hrs Information Technology Training

Board of Studies, ICAI

1. Create a new
workbook and
enter any data
that you want to
provide, or open
an existing
workbook that you
want to make
available for
multiuser editing.

Use Shared Workbook to


Collaborate

2. On the Review
tab, in the
Changes group,
click Share
Workbook.
3. On the Editing
tab, select the
Allow changes
by more than
one user at the
same
time.
This Training
100hrs
Information
Technology

Board of Studies, ICAI

4. On the
Use
Shared
Advanced tab,
select the
Collaborate
options
that you want to
use for tracking
and updating
changes, and
then click OK.
5. Do one of the
following:
If this is a new
workbook, type a
name in the File
name box.
If this is an existing
workbook, click OK to
save the workbook,
click Microsoft
Office Button , and
then Information
click Save
As. Training
100hrs
Technology

Workbook to

Board of Studies, ICAI

Use Shared Workbook to


Collaborate

6. In the Save in box,


select a network
location that is
accessible to the
intended users, and
then click Save.

7. If the workbook
contains links to other
workbooks or
documents, verify the
links and update any
links that are broken,
and then click Save
on the Quick Access
Toolbar, or press
CTRL+S.

100hrs Information Technology Training

Board of Studies, ICAI

Using the
The conversion
feature Feature
allows you
to open
worksheets
created by other
programs and
convert them to
Excel 2007
worksheets,
convert formulas
into the values
they display, and
convert graphic
objects into
bitmapped
graphics

Conversion

.
100hrs Information Technology Training

Board of Studies, ICAI

Sample ITT Questions

100hrs Information Technology Training

Board of Studies, ICAI

Answers

1. A
2. C
3. B
4. D
5. D
6. A
7. D

100hrs Information Technology Training

Board of Studies, ICAI

Вам также может понравиться