Excel Macros
Excel Macros
Excel Macros
Most of us in the industry will surely have certain tasks that are to be
performed repeatedly almost every day. Now imagine if those tasks are
done with just a single click. Sounds exciting? Excel Macros is the
answer to that.
What Are Excel Macros
• A macro is a set of actions that you can run to perform the desired
task.
• Suppose every month you create a report that needs to mark the user
accounts with the overdue amount in bold and red. Then you can
create and run a macro that applies these formatting changes every
time you wish to.
How To Enable Macros In Excel
• The Developer tab gives us the ability to work with features like
Macros, Add-ins, and also allows us to write our own VBA code that
will help us to automate anything we wish. This tab is hidden by
default.
• Note: This is a one-time process. Once you enable the Developer Tab,
it will always be shown in a custom ribbon for every Excel instance you
open, unless you go ahead and disable it explicitly.
Developer Tab’s Options
• Visual Basic: Gives an Editor to write or edit VBA code. Can also be
opened using Alt+F11.
• Macros: Gives the list of all the already recorded macros and is also
used to record a new one. Alt+F8 will directly open the list of macros.
• Add-ins: Allows to Insert an Add-In and can also manage them.
• Controls: Helps us in using Form controls and ActiveX controls. Viewing
and editing the control properties. Design Mode ON/OFF is controlled
here.
• XML: Helps us to Import/Export an XML data file, to manage XML
expansion packs, and also to open the XML Source task pane.
How To Record A Macro
• Your company has a certain tool which generates timesheets for various
departments in Excel. You as a manager have the responsibility of reviewing and
sending the sheet to the finance team every week.
• But before sending you are asked to make some formatting like:
1) Insert the Title for every sheet that includes team name and week number, mark
it bold, and background yellow.
2) Draw a border
3) Bold the column headings.
4) Rename the sheet name as the team name.
• Instead of doing this manually every week, you can just create a macro and
perform all these actions in just a click.
• Recording macro is fairly easy. Navigate to the Developer tab, and hit
on Record Macro.
• This will open up a window where you need to enter.
1) Macro name: Name should not have spaces in between words. This has to
start with an alphabet or underscore.
2) Shortcut key: This is useful when you are running a macro. If you press the
shortcut key, it will be executed. Make sure to give a key which is not
already taken, else macro will override that.
3) Store macro in: This has 3 options as given below:-
a) This Workbook: All the macros created will only be available to the current
workbook. If you open a new excel then the macro created earlier won’t be available
and hence it can’t be used.
b) Personal Macro Workbook: If you select this, then the macro created will be stored
and will be shown when you open a new excel sheet.
c) New Workbook: This option will open a new workbook and the actions performed in
that workbook will be recorded.
4) Description: This will describe the purpose of the macro. It is recommended
to give a detailed description so that anyone using that will know what
exactly it is used for.
• Once you fill in the details for the fields mentioned above, you can go ahead and
perform the actions required in the Excel Workbook and everything will be
recorded. Once done, go back to the Developer tab and hit on Stop Recording.
Saving An Excel Workbook With Macro
• Selecting Store macro in as “This Workbook”: Consider that you have
selected the Store macro in as “This Workbook” while recording.
Once done go ahead and save the file. While saving you need to
select Excel Macro-Enabled Workbook. You don’t have to explicitly
save the macro. It gets saved automatically.
• Selecting Store macro in as “Personal Macro workbook”: Now
consider selecting the Store macro in as “Personal Macro workbook”
while recording. You need to save the macro explicitly. If you just save
the Excel file and then try to close the file. Then you will receive a
pop-up dialog as shown below.
• Note: If you don’t save this then the macro will be deleted.
Thank You…!!