02 Create Excel Macros Without Programming - J.A. Gomez
02 Create Excel Macros Without Programming - J.A. Gomez
This publication is licensed for your personal enjoyment only. If you would like to
share this publication with another person, please purchase an additional copy for
each recipient. If you are reading this publication and did not purchase it, or it was
not purchased for your use only, then please return to Amazon.com and purchase
your own copy. Thank you for respecting the hard work of the Publisher and Author.
Trademarked names, logos and images may appear in this publication. Rather than
use a trademark symbol with every occurrence of a trademarked name, logo or
image, the names, logos and images are used only in an editorial fashion to the
benefit of the trademark owner, with no intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar
terms, even if they are not identified as such, is not to be taken as an expression
of opinion as to whether or not they are subject to proprietary rights. Additionally,
use of a term in this publication should not be regarded as affecting the validity of
any trademark.
2
Create Excel Macros Without Programming
The Publisher and the Author make no representations or warranties with respect
to the accuracy or completeness of the contents of this publication and specifically
disclaim all warranties, including without limitation warranties of fitness for a
particular purpose. No warranty may be created or extended by sales or
promotional materials.
The information provided in this publication is for information purposes only and is
provided on an "as is" basis. The advice and strategies contained herein may not
be suitable for every situation. Users of this publication are advised to carry out
their own due diligence when it comes to making decisions related (directly or
indirectly) to the contents of this publication.
This publication is sold with the understanding that the Publisher and the Author
are not engaged in rendering legal, accounting, technical or other professional
services. If professional assistance is required, the services of a qualified
professional should be sought. All information, products and services that are
mentioned or provided in this publication should be independently verified by your
own qualified professionals.
Neither the Author, the Editors nor the Publisher shall be liable nor responsible for
any errors or omissions that may be made in this publication, nor for any damages
arising (directly or indirectly) from this publication.
By using this publication, you agree that the Author, the Publisher and any related
(directly or indirectly) persons or parties are not responsible for the success or
failure of any decisions or actions related (directly or indirectly) to any information
presented in this publication. The Author and Publisher shall have neither liability
nor responsibility to any person or entity with respect to any loss or damages
arising (directly or indirectly) from the information contained in this publication.
3
Create Excel Macros Without Programming
4
Create Excel Macros Without Programming
Table of Contents
Introduction .............................................................................................. 12
Introduction ........................................................................................... 16
Introduction ........................................................................................... 23
The Impact of Planning and Setup on the Quality of Recorded VBA Code ..... 24
5
Create Excel Macros Without Programming
The Choice Between Absolute and Relative References When Recording Macros
.......................................................................................................... 30
Introduction ........................................................................................... 39
Step #3: Specify the Macro's Details with the Record Macro Dialog Box ....... 41
6
Create Excel Macros Without Programming
Introduction ........................................................................................... 52
The Macro Recorder May Fail to Capture the Logic Behind Certain Features .... 53
AutoSum ............................................................................................. 53
Introduction ........................................................................................... 71
Next Steps................................................................................................ 74
7
Create Excel Macros Without Programming
Table of Figures
Figure 1: The Ribbon does not display the Developer tab by default. ................ 17
Figure 2: To display the Developer tab (steps #1 and #2): Right-click the Ribbon
→ select Customize the Ribbon.................................................................... 17
Figure 6: Relative cell references adjust when copied to another location. ........ 27
Figure 8: When you copy the formula in cell C8 to other cells, Excel adjusts the
relative cell references. .............................................................................. 28
Figure 9: Absolute cell references do not adjust when copied to another location.
............................................................................................................... 28
Figure 11: When you copy the formula in cell C9 to other cells, Excel does not
adjust the absolute cell references. .............................................................. 29
Figure 13: Cell A5 is selected while the Macro Recorder is on. ......................... 31
Figure 14: If A10 is the active cell prior to macro execution, both macros select cell
A5. .......................................................................................................... 31
Figure 15: If B10 is the active cell prior to macro execution, the macro recorded
with absolute references selects cell A5. ....................................................... 32
Figure 16: If B10 is the active cell prior to macro execution, the macro recorded
with relative references selects cell B5. ........................................................ 32
Figure 17: Cell A7 is selected prior to recording macro. Cells A5 and A6 contain
values. ..................................................................................................... 35
Figure 18: A worksheet formula is entered in the active cell while the Macro
Recorder is on. .......................................................................................... 35
8
Create Excel Macros Without Programming
Figure 19: The Use Relative References button is in the Code group of commands
of the Developer tab. ................................................................................. 36
Figure 20: When the Use Relative References button is of a darker shade, you are
recording with relative references. ............................................................... 36
Figure 21: You can use the Go To dialog box to create an absolute reference to a
cell while recording a macro. ....................................................................... 37
Figure 22: In this Chapter, you create a macro that enters and formats text in the
active worksheet. ...................................................................................... 40
Figure 23: Use relative references when recording the macro example. ............ 41
Figure 24: Use the Record Macro button in the Developer tab or the Status bar. 41
Figure 29: This Workbook is the default macro storage option. ........................ 44
Figure 31: Excel displays the Stop Recording button while you record a macro. . 45
Figure 32: Format the active cell as bold and enter text. ................................ 46
Figure 35: Select the cells containing text and autofit the column width. .......... 46
Figure 36: Select cells and specify their font color. ........................................ 47
Figure 37: Use the Stop Recording button in the Developer tab or the Status bar.
............................................................................................................... 47
Figure 38: Every time you press the assigned keyboard shortcut, Excel executes
the macro. ................................................................................................ 48
Figure 39: Save a Macro-Enabled Workbook (steps #1 and #2): Open the Save As
dialog box → enter the file name. ................................................................ 49
9
Create Excel Macros Without Programming
Figure 40: Save a Macro-Enabled Workbook (steps #3 and #4): Expand the Save
as type drop-down list → select Excel Macro-Enabled Workbook. ..................... 50
Figure 41: Save a Macro-Enabled Workbook (step #5): Click Save. ................. 50
Figure 42: Both tables have a single column, but the table in column C has one
more row. ................................................................................................ 53
Figure 44: Enter data in the Record Macro dialog box. .................................... 54
Figure 45: AutoSum identifies the appropriate cells to work with. .................... 55
Figure 46: The recorded macro fails to identify the appropriate cells to work with.
............................................................................................................... 55
Figure 47: The tables have a different number of rows and columns. ............... 56
Figure 49: Enter data in the Record Macro dialog box. .................................... 57
Figure 50: While recording the macro: Select the data around the active cell. ... 57
Figure 51: While recording the macro: Click Quick Analysis Tool → select Totals →
select Sum. .............................................................................................. 57
Figure 52: The Quick Analysis Tool identifies the appropriate cells to work with. 58
Figure 53: The recorded macro fails to identify the appropriate cells to work with.
............................................................................................................... 58
Figure 54: The tables are the same size, but the second table contains an empty
cell. ......................................................................................................... 59
Figure 56: Enter data in the Record Macro dialog box. .................................... 60
Figure 57: Ctrl+Down Arrow takes you to the bottom edge of the current data
region. ..................................................................................................... 61
Figure 58: The recorded macro does not necessarily take you to the last row. .. 61
Figure 59: VBA allows you to work with additional tools and features. .............. 63
Figure 60: Enter data in the Record Macro dialog box. .................................... 64
10
Create Excel Macros Without Programming
Figure 62: When you work with the Page Setup dialog box, the Macro Recorder
generates code that regulates all the settings in the dialog box. ...................... 67
Figure 63: To delete a macro with the Macro dialog box (steps #1 to #3): Go to
the Macro dialog box → select the macro → click Delete. ................................ 72
Figure 64: To delete a macro with the Macro dialog box (steps #4 and #5): Click
Yes to confirm the macro deletion................................................................ 72
11
Create Excel Macros Without Programming
Introduction
About this Book
As implied by its title, the main purpose of this Book is to help you start creating
macros without programming.
As I explain in Introduction to Excel Macros & VBA, my experience is that the main
reason people shy away from working with macros and VBA is because these tools
are usually associated with programming.
However, as you learn in this Book, the association several people make between
macros and programming is not always correct. You can work with basic macros
without programming.
In other words, Excel has a set of tools and features that allow you start creating,
and working with, macros even if you have no programming knowledge or
experience.
One of the main goals of this Book is to help you during the first stages of learning
how to work with macros and VBA. I am mindful that to learn about, and master,
Excel macros and VBA you need to take the right approach.
In this Book, you learn about certain Excel tools and features that are designed to
help you work with, and learn about, macros. You can apply the principles,
processes and strategies you learn in this Book to create basic but very powerful
macros.
In the short term, this Book should help you start creating basic but useful macros.
In the medium and long term, the tools and features you learn about help build the
knowledge foundation you need to become a powerful Excel macro and VBA user.
The learning techniques and strategies I use in the following Chapters were first
applied to my own process of mastering macros and VBA.
12
Create Excel Macros Without Programming
• Spain;
• South Korea;
• Singapore;
• Germany; and
• Canada.
• Automation;
• Excel;
• Macros; and
• VBA.
At times, I faced common self-limiting beliefs and doubts. These beliefs ranged
from believing I was not very good at Math to thinking I would never be able to
learn how to program.
I was soon proved wrong. From the moment I decided to focus on Finance, data
analysis, automation and Excel, I have achieved a lot. This includes obtaining a
Masters in Quantitative Finance with Merit and offers for several good-paying jobs
(in a variety of countries and industries) where advanced knowledge of Excel was
a requirement.
The main reason I share my story is because I firmly believe that, if I could
overcome my limitations and self-limiting beliefs to master Excel macros and VBA,
you also can. I did not have any unique gifts, traits or experiences to indicate that
I would be able to become an authority in the field of Excel macros and VBA.
13
Create Excel Macros Without Programming
I decided to learn about these topics. I have invested a lot of time and money
towards achieving this goal. This experience of learning about Excel macros and
VBA has allowed me to organize and structure the information anybody, like you,
needs to learn about these topics.
• In Chapter 1, you learn how to set up Excel to work with macros and VBA.
• In Chapter 2, you learn about the tool (known as the Macro Recorder) you
work with when creating Excel macros without programming.
• In Chapter 3, you learn how to plan and prepare prior to creating a macro
without programming.
• In Chapter 4, you learn about one of the most important choices you make
prior to recording a macro: Whether to use absolute or relative cell references.
• In Chapter 5, you learn the step-by-process you can follow to create Excel
macros without programming.
• How to determine whether a specific situation is suitable for using the Macro
Recorder.
More Information
This Book is accompanied by a website where you can download several files
containing the data and macros used in this Book's examples. The example files
inside the Book's website are organized according to the Chapters and Sections of
this Book. This makes it easy for you to find what you need as you read along.
• Get immediate free access to the example files that accompany this Book.
14
Create Excel Macros Without Programming
In addition to authoring this Book, J.A. Gomez is the creator of one of the most
successful Excel macro and VBA websites. You can learn more about J and obtain
free supplemental training materials at PowerSpreadsheets.com.
15
Create Excel Macros Without Programming
• Why you must set up Excel to work with macros and VBA.
• What commands and command groups are accessed through the Developer
tab.
• What (two) buttons of the Developer tab you work with when creating macros
without programming.
Introduction
If you are planning to work with macros and VBA, you must have access to the
right tools and features. However, Excel does not display by default the set of tools
and features you use when working with macros and VBA.
Therefore, before you start creating macros or working with VBA code, you must
gain access to these tools and features.
For these purposes, you follow a simple process that gets Excel to display an
additional Ribbon tab. You usually do this only once, unless you are constantly:
As implied by its name, the Developer tab contains several commands Excel
Developers (like you) use. As you learned in the previous Section, the Developer
tab is hidden by default.
16
Create Excel Macros Without Programming
Figure 1: The Ribbon does not display the Developer tab by default.
#2. Select Customize the Ribbon in the context menu displayed by Excel.
Figure 2: To display the Developer tab (steps #1 and #2): Right-click the Ribbon → select Customize the Ribbon.
#3. Excel displays the Customize Ribbon tab of the Excel Options dialog box.
The list box located on the right side of the Excel Options dialog box includes all
the main Ribbon tabs.
• The checkboxes of the tabs that are currently displayed in the Ribbon have
a checkmark.
• The Developer checkbox is located near the end of this list and, by default,
does not have a checkmark.
17
Create Excel Macros Without Programming
Figure 3: To display the Developer tab (steps #3 to #5): Add checkmark to Developer tab checkbox → click OK.
After you complete this process, Excel adds the Developer tab to the Ribbon.
#1. Code.
#2. Add-ins.
#3. Controls.
#4. XML.
18
Create Excel Macros Without Programming
As you learn in Chapters 4 and 5, these commands are essential to create macros
without programming.
More generally, you use the buttons in the Code group of commands to:
• Create macros;
• Execute macros.
• The Controls group of commands gives you access to several controls you can
use in your worksheets or UserForms. UserForms allow you create custom dialog
boxes.
• The Add-ins group of commands allows you to work with, and manage, add-
ins.
• The XML group of commands allows you to work with XML files. The main
purpose of XML files is to store and transport data.
19
Create Excel Macros Without Programming
• Excel does not display the Developer tab by default. You can, however, get
Excel to display the Developer tab by customizing the Ribbon with the Excel
Options dialog box.
#1. Code;
#2. Add-ins;
#4. XML.
• To create macros without programming, you work with two buttons from the
Code group of commands:
20
Create Excel Macros Without Programming
• The two main ways in which you can create macros when working with Excel.
• What the Macro Recorder (the tool you use to create macros without
programming) is.
• The basic process you follow to create macros with the Macro Recorder.
• Why the Macro Recorder is such an important and useful tool for Excel macro
and VBA users of all levels.
In this Book, you learn how to create macros without programming. Therefore, you
focus on learning how to work with the Macro Recorder.
In other words, the Macro Recorder allows you to create macros by following a
three-step process:
As you manually carry out the activities you want to record (step #2), the Macro
Recorder works behind the scenes to:
21
Create Excel Macros Without Programming
• Create a macro.
After the macro is recorded, you can command Excel to execute the macro as, and
when, required.
There are several reasons why you may want to, later, learn to code in VBA.
However, in this Book you learn how to create Excel macros without programming.
The Macro Recorder is the tool that allows you to do this.
• As a beginner, you may find that the Macro Recorder is great for creating
simple macros.
• At more advanced levels, you are likely to find that the Macro Recorder has
important uses and (usually) continues to play a role in the process of macro
creation.
• The Macro Recorder allows you to create macros by manually carrying out (and
recording) the activities you want to automate. The Macro Recorder does this by
converting your actions into VBA code.
• The Macro Recorder is commonly used by Excel macro and VBA users of all
levels.
22
Create Excel Macros Without Programming
• The reasons why you must usually carry out some planning and setup activities
prior to recording a macro.
• The questions you can ask yourself to determine the appropriate setup prior
to recording a macro.
Introduction
In Chapter 2, you learned that recording a macro with the Macro Recorder is the
easiest way to create basic macros.
Although the process of creating a macro with the Macro Recorder is very easy,
you usually do some planning or setup work prior to recording the macro.
At a basic level, you usually want to ensure the appropriate conditions for recording,
and later executing, the macro are met. You can usually start by answering the
following questions:
• How should you set up the workbook you are working on?
• Should the Macro Recorder record absolute or relative references to the cell
ranges you work with? You learn how to choose between recording absolute and
relative references in Chapter 4.
• What do you want to achieve? What is the purpose of the macro you want to
record?
23
Create Excel Macros Without Programming
• In which context do you expect to use the recorded macro? Should the macro
have a broad or a restricted scope?
• Do the expectations you have influence the setup of the Excel workbook prior
to recording the macro? Should the macro itself carry out part of the set-up
work?
• Records virtually everything you do while the Macro Recorder is turned on;
and
• Translates it to VBA.
• Mistakes;
• Inaccurate indications.
#2. Recorded VBA code includes additional statements reflecting any recording
mistakes, unnecessary movements and inaccurate indications.
24
Create Excel Macros Without Programming
Longer and verbose code is more difficult to work with than short and concise code.
Shorter and concise macros are also easier to edit and fix (if necessary).
In other words, your objective is to have the least amount of VBA code possible to
appropriately handle the task at hand. When recording a macro, you usually
achieve this by:
• Avoiding mistakes.
• Prior to recording a macro, you should usually answer the following questions:
• How should you set up the Excel workbook you are working on?
• Should you use absolute or relative references while recording the macro?
• Avoid mistakes.
25
Create Excel Macros Without Programming
• How you work with relative and absolute cell references when dealing with
worksheet formulas.
• How the Macro Recorder keeps track of the cells you select and work with while
recording a macro.
• The main consequences that the choice of absolute or relative cell references
has on recorded macros.
• Why worksheet formulas you enter while recording a macro are not affected
by the absolute or relative cell references setting of the Macro Recorder.
• How you specify whether the Macro Recorder uses absolute or relative
references.
• How to toggle between absolute and relative reference use while recording a
macro.
In other words:
26
Create Excel Macros Without Programming
• Failure to make the right choice (between absolute and relative references)
usually results in recorded macros that do not work as expected. This may be
the case even if the rest of your setup prior to recording the macro is flawless.
Consider, for example, cell C8 in the worksheet displayed in Figure 7 below. The
formula in this cell refers to cell A5 using relative references (=A5).
If you copy the formula in cell C8 and paste it in cells D8 to G8, Excel adjusts the
cell references. Therefore:
27
Create Excel Macros Without Programming
Figure 8: When you copy the formula in cell C8 to other cells, Excel adjusts the relative cell references.
Figure 9: Absolute cell references do not adjust when copied to another location.
When you copy and paste worksheet formulas to another location, Excel does not
automatically adjust absolute cell references.
Consider, for example cell C9 in the worksheet displayed in Figure 10 below. The
formula in this cell refers to cell A5 using absolute references (=$A$5).
If you copy the formula in cell C9 and paste it in cells D9 to G9, Excel does not
adjust the cell references. Therefore, all cells continue to refer to cell A5.
28
Create Excel Macros Without Programming
Figure 11: When you copy the formula in cell C9 to other cells, Excel does not adjust the absolute cell references.
When you record macros, the Macro Recorder keeps track of the cells you:
• Select; and
• Work with.
• Do not change.
• Literal; and
• Strict.
Macros that work with absolute references always work with the same cells.
Therefore, macros recorded with absolute references are (usually) not flexible
enough to be used in a variety of circumstances. In other words, recording macros
with absolute references tends to result in macros that do not work appropriately.
Because of these reasons, you usually do not record macros with absolute
references.
29
Create Excel Macros Without Programming
When you use relative references while recording, the Macro Recorder keeps track
of the cells you work with by referring to the active cell. In other words:
• The recorded VBA code moves a specific number of rows and columns from
that starting point (the active cell) to find the new cell.
Relative references are less strict than absolute references. Therefore, they usually
result in more flexible and generic macros that you can use in a wider variety of
circumstances.
As you learned in previous Sections, the results of executing a recorded macro may
vary substantially depending on whether the macro was recorded with absolute or
relative references.
• When you record a macro with absolute references, the macro always works
with the same cells.
• When you record a macro with relative references, Excel determines the cell(s)
to work with by reference to the current active cell. Therefore, the cell(s) the
macro works with depend on the active cell prior to executing the macro.
30
Create Excel Macros Without Programming
In other words, both macros select a cell. The cell that is selected upon macro
execution depends on two main factors:
#1. The macro version (with absolute or relative references) you execute; and
#1. If the active cell prior to macro execution is cell A10, both macros select cell
A5.
Figure 14: If A10 is the active cell prior to macro execution, both macros select cell A5.
#2. If the active cell prior to macro execution is cell B10, the macros select
different cells, as follows:
31
Create Excel Macros Without Programming
• The macro that works with absolute references selects cell A5.
Figure 15: If B10 is the active cell prior to macro execution, the macro recorded with absolute references selects cell
A5.
• The macro that works with relative references selects cell B5.
Figure 16: If B10 is the active cell prior to macro execution, the macro recorded with relative references selects cell
B5.
The differences in the selected cells are the result of how each macro determines
the cell to select.
• The macro that is recorded with absolute references always selects cell A5.
• The macro that is recorded with relative references selects the cell five rows
above the current active cell. Therefore:
• If the active cell is cell A10 (as when the macro is recorded), the macro
selects cell A5 (five rows above) when executed.
• If the active cell is cell B10, the macro selects cell B5 (five rows above)
when executed.
The differences in behavior between macros with absolute and relative references
are a consequence of the differences in the recorded VBA code. In other words, the
Macro Recorder creates different VBA code depending on whether you record
macros with absolute or relative references.
In the previous Section, you analyzed the behavior of two example macros that
select a cell. These macro examples:
32
Create Excel Macros Without Programming
• Only differ on the type of cell references (absolute vs. relative) they use.
The following are the VBA statements generated by the Macro Recorder:
For purposes of this Book, you do not need to understand all details of these
statements. Simply notice the following:
• When working with absolute references, the Macro Recorder hard-codes the
cell address. In this example, Range("A5") refers to cell A5 of the active
worksheet.
• When working with relative references, the Macro Recorder does the following:
• Moves five rows up while remaining in the same column as the active cell
(Offset(-5, 0)).
To summarize:
• When the macro is recorded with absolute references, the Macro Recorder
hard-codes a cell address.
• When the macro is recorded with relative references, the Macro Recorder
determines the cells to work with by reference to a base, which is initially the
active cell.
The differences between absolute and relative references influence how you set
Excel up prior to recording a macro.
33
Create Excel Macros Without Programming
When recording a macro with absolute references, you usually select the cells you
work with after you turn the Macro Recorder on. This is because these macros
always work with the same cells. By selecting the cells you work with after you
begin recording, you ensure the appropriate cell addresses are hard-coded in the
resulting VBA code.
When recording a macro with relative references, you usually select the first cell(s)
you work with before turning the Macro Recorder on. This is because these macros
use the active cell as the base from which they determine the cells to work with
and manipulate.
Despite this, worksheet formulas entered by recorded macros are not affected by
the absolute or relative cell references setting of the Macro Recorder. In other
words, if you enter a worksheet formula while recording a macro:
• You enter it as usual and without any consideration for the macro recording
setting (absolute or relative references).
• The worksheet formula stored in the recorded VBA code is the same regardless
of the macro recording setting (absolute or relative references).
34
Create Excel Macros Without Programming
Figure 17: Cell A7 is selected prior to recording macro. Cells A5 and A6 contain values.
Figure 18: A worksheet formula is entered in the active cell while the Macro Recorder is on.
When cell A7 is the active cell and the macros are executed, both macros enter the
same worksheet formula (=SUM(A5:A6)).
In fact, the VBA statement generated by the Macro Recorder is the same regardless
of the use of relative or absolute cell references: ActiveCell.FormulaR1C1 =
"=SUM(R[-2]C:R[-1]C)". Notice the following:
• Both macros enter the same worksheet formula that uses the SUM function
(=SUM(R[-2]C:R[-1]C)).
35
Create Excel Macros Without Programming
Figure 19: The Use Relative References button is in the Code group of commands of the Developer tab.
• If the button is of the same color as the other Ribbon buttons (the default),
you are recording with absolute references.
• If the button is of a darker shade of gray than the other Ribbon buttons, you
are working with relative references.
Figure 20: When the Use Relative References button is of a darker shade, you are recording with relative references.
• When you are recording with relative references but, for a part of the macro,
need to create absolute references; or
• Vice-versa, when you are recording with absolute references but, for a part of
the macro, need to create relative references.
This keyboard shortcut works for English (United States) language settings.
Depending on your language settings, you may have to use a different keyboard
shortcut to achieve the same result.
36
Create Excel Macros Without Programming
#3. Enter the address of the cell you want to go to in the Reference field.
Figure 21: You can use the Go To dialog box to create an absolute reference to a cell while recording a macro.
When you create absolute cell references by using the Go To dialog box, the Macro
Recorder usually hard-codes the cell address.
Strictly speaking, the VBA construct used by the Macro Recorder to create absolute
references differs depending on whether you create it by:
• When executed, the macro selects the same cell always regardless of what the
current active cell is; and
• The Macro Recorder generates VBA code where the cell address is hard-coded.
• When you work with worksheet formulas, cell references are relative by
default. When you copy worksheet formulas with relative references to another
location, Excel adjusts cell references automatically.
• You can create worksheet formulas that use absolute cell references. When
you copy worksheet formulas with absolute references to another location, Excel
does not adjust those cell references.
37
Create Excel Macros Without Programming
• The Macro Recorder keeps track of the cells you select and work with while
recording a macro.
• You can record macros that use relative cell references. The resulting
macros are usually flexible enough to be used in a wide variety of
circumstances.
• The VBA code of recorded macros usually reflects your use of absolute or
relative references while recording.
• When recording a macro with absolute references, you usually select the cells
you work with after turning the Macro Recorder on. This ensures the appropriate
cell addresses are hard-coded in the VBA code.
• When recording a macro with relative references, you usually select the first
cell(s) you work with before turning the Macro Recorder on. This ensures the
macro uses the active cell as the initial base to determine the cells to work with.
• The worksheet formulas you enter while recording a macro are not affected by
the absolute or relative cell references setting of the Macro Recorder.
• You specify whether the Macro Recorder uses absolute or relative references
by working with the Use Relative References button.
• You can use the Use Relative References button while recording a macro. This
allows you to toggle between absolute and relative references while recording a
single macro.
• You can also create an absolute cell reference while recording a macro by using
the Go To dialog box.
38
Create Excel Macros Without Programming
• Name; and
• Description.
• How to:
• The two basic rules to follow when choosing the name of a recorded macro.
Introduction
In Chapter 2, you learned the following:
• The Macro Recorder allows you to create macros without having to code.
• When working with the Macro Recorder, you create macros by following a
three-step process:
In Chapters 3 and 4, you learned that, although working with the Macro Recorder
is the easiest way to create a macro, you usually do some planning or setup work
prior to recording a macro.
39
Create Excel Macros Without Programming
• Learn more details about the process you follow when creating a macro with
the Macro Recorder; and
#3. Changes the font color of the two cells below the active cell.
Figure 22: In this Chapter, you create a macro that enters and formats text in the active worksheet.
This is a simple macro. However, you can apply the same principles and process
you learn in this Chapter to create other basic but powerful macros.
Therefore, before you start working with the Macro Recorder, ensure Excel is
working with the appropriate cell references (absolute or relative).
The macro example you create in this Chapter always works with:
40
Create Excel Macros Without Programming
In other words, the recorded macro must always determine the cells it works with
by reference to the current active cell. These are relative references.
Figure 23: Use relative references when recording the macro example.
Figure 24: Use the Record Macro button in the Developer tab or the Status bar.
Step #3: Specify the Macro's Details with the Record Macro Dialog
Box
After you turn the Macro Recorder on, Excel displays the Record Macro dialog box.
This dialog box allows you to enter the following four details:
41
Create Excel Macros Without Programming
#4. Description.
Enter the appropriate data (as explained in the Sections below) in the Macro dialog
box and click the OK button.
Macro Name
You usually want to enter a more descriptive and meaningful name. Macro names
must comply with several rules. For purposes of this Book, ensure your macro name
complies with the following two requirements:
For purposes of the example you create in this Chapter, use "enterIdData".
Shortcut Key
When recording macros, you have the option to assign a shortcut key combination
that (later) launches the macro. This field is not required.
42
Create Excel Macros Without Programming
• Ctrl+Key; or
• Ctrl+Shift+Key.
When you specify the key combination in the Record Macro dialog box, you omit
the Ctrl key. In other words, you only type the:
• Key; or
• Shift+Key combination.
For purposes of the example you create in this Chapter, assign the keyboard
shortcut Ctrl+Shift+E. Therefore, press Shift+E.
Store Macro In
Use the Store macro in drop-down list to select the workbook in which your macro
is stored. You have the following three options:
#3. Personal Macro Workbook, which refers to the Personal Macro Workbook.
43
Create Excel Macros Without Programming
This Workbook is the default option and results in the VBA code of the recorded
macro being stored in the current active workbook. Therefore, the macro is
available to you and other users that work with that workbook.
New Workbook, as implied by its name, results in Excel creating a new workbook
where the recorded VBA code is stored.
The Personal Macro Workbook is a special workbook you can normally use as
storage for macros you constantly use in different files. You can learn more about
the Personal Macro Workbook in Introduction to Excel Macro Security and Storage.
For purposes of the example you create in this Chapter, leave the default option:
This Workbook.
Description
The last field of the Record Macro dialog box allows you to enter a description of
the macro. This helps you and other users:
44
Create Excel Macros Without Programming
For purposes of the example you create in this Chapter, type "Enters and formats
identification text, starting in the active cell."
Figure 31: Excel displays the Stop Recording button while you record a macro.
While the Macro Recorder is on, you carry out the actions you want to record.
For purposes of the example you create in this Chapter, do the following:
#1. Make the text in the active cell bold by, for example, pressing the Ctrl+B
keyboard shortcut.
#3. Press the Ctrl+Enter keyboard shortcut to confirm the entry while
remaining in the same cell.
45
Create Excel Macros Without Programming
Figure 32: Format the active cell as bold and enter text.
#4. Press the Down Arrow key to move one cell down.
#6. Press the Ctrl+Enter keyboard shortcut to confirm the entry while
remaining in the same cell.
#7. Press the Down Arrow key to move one cell down.
#9. Press the Ctrl+Enter keyboard shortcut to confirm the entry while
remaining in the same cell.
#10. Press the Up Arrow key twice to select the cell containing "Create Excel
Macros Without Programming".
#11. Press the Shift key and, while keeping it pressed, press the Down Arrow
key twice to expand the selection to include the cells containing your name and
"Power Spreadsheets".
#12. Autofit the column width by, for example, using the Alt, H, O, I keyboard
shortcut.
Figure 35: Select the cells containing text and autofit the column width.
#13. Press the Down Arrow key to move one cell down and select the cell
containing your name.
46
Create Excel Macros Without Programming
#14. Press the Shift+Down Arrow keyboard shortcut to expand the selection to
include the cell containing "Power Spreadsheets".
#15. Expand the font-color gallery in the Home tab of the Ribbon and select a
gray color.
The keyboard shortcuts I use in the process described above work for English
(United States) language settings. Depending on your language settings, you may
have to use different keyboard shortcuts to achieve the same results.
Figure 37: Use the Stop Recording button in the Developer tab or the Status bar.
After you click the Stop Recording button, it is replaced by the Record Macro button.
47
Create Excel Macros Without Programming
However, as you learned in a previous Section, you can easily assign a keyboard
shortcut to any recorded macro you create. Keyboard shortcuts are, therefore, a
very common way to execute recorded macros.
You can execute the macro example created in this Chapter by pressing the
Ctrl+Shift+E keyboard shortcut as required.
Figure 38: Every time you press the assigned keyboard shortcut, Excel executes the macro.
Each time you execute the macro example, it works with the active cell and the
two cells below it. This is a result of you:
• At a basic level, the fact that not all Excel files can contain macros helps you
control your own security.
• At a broader level, this feature influences the file formats you can use when
working with macros and VBA.
Therefore, this security feature has direct consequences on the way in which you
save workbooks that contain macros (like the one you created in this Chapter).
48
Create Excel Macros Without Programming
• Very important.
Therefore, I suggest you learn more about macro security after completing this
Book. You can learn about this topic in Introduction to Excel Macro Security and
Storage.
For purposes of this Book, is enough for you to understand that (generally) Excel
workbooks containing macros should be saved as Macro-Enabled Workbooks (.xlsm
extension). If you save your workbook using the default Excel Workbook file type
(.xlsx extension), Excel removes your macros prior to saving the file.
#1. Open the Save As dialog box by, for example, pressing the F12 key.
This keyboard shortcut works for English (United States) language settings.
Depending on your language settings, you may have to use a different keyboard
shortcut to achieve the same result.
#2. Specify the file name. For purposes of the example you created in this
Chapter, enter "Recorded Macro".
Figure 39: Save a Macro-Enabled Workbook (steps #1 and #2): Open the Save As dialog box → enter the file name.
49
Create Excel Macros Without Programming
Figure 40: Save a Macro-Enabled Workbook (steps #3 and #4): Expand the Save as type drop-down list → select
Excel Macro-Enabled Workbook.
After you complete this process, Excel saves your file as a Macro-Enabled Workbook
containing the macros you created and stored in that workbook.
#1. Ensure you are working with absolute or relative references, as required.
#3. Specify the macro's details in the Record Macro dialog box.
• Name: For the moment, specify a macro name that starts with a letter
and contains no spaces.
50
Create Excel Macros Without Programming
• Workbook where macro is stored: For the moment, store macros in the
workbook you are working with (This Workbook). This is the default option.
• Description (optional).
• If you assign a keyboard shortcut to a recorded macro, you can use this
keyboard shortcut to execute the macro when required.
51
Create Excel Macros Without Programming
• How the Macro Recorder may fail to capture and reflect the logic behind certain
Excel features.
• Why, despite its limitations, the Macro Recorder continues to be useful for both
beginner and advanced macro and VBA users.
Introduction
As you learned throughout this Book, the Macro Recorder can be extremely useful.
However, the Macro Recorder is not perfect. In fact, there are some important
limitations. A better understanding of the limitations of the Macro Recorder, and its
common uses, helps you:
In this Chapter, you learn about the following four main limitations of the Macro
Recorder:
#1. The Macro Recorder does not record absolutely everything you do manually.
#2. The Macro Recorder sometimes fails to adequately capture or reflect the
logic behind certain Excel features or operations.
52
Create Excel Macros Without Programming
#3. The Macro Recorder is limited to manual actions and cannot reflect or work
with several VBA features.
#4. The Macro Recorder generates VBA code that is usually inefficient and long.
There are, however, cases where the Macro Recorder fails to generate the code
that reflects a specific command or action. This is the case, for example, with some
actions you carry out with the Ribbon.
• AutoSum;
• The keyboard shortcut that takes you to the edge of the current data region.
AutoSum
Consider, for example, the two tables (cells A5 to A8 and C5 to C9) displayed in
Figure 42 below. These tables have a single column, but a different number of rows.
Figure 42: Both tables have a single column, but the table in column C has one more row.
These tables illustrate the inability of the Macro Recorder to adequately capture the
logic behind Excel's AutoSum feature.
53
Create Excel Macros Without Programming
#1. Enable relative references by clicking the Use Relative References button in
the Developer tab.
#5. Enter a macro name (for example, "useAutoSum") and assign a keyboard
shortcut (for example, Ctrl+Shift+A).
#7. Execute the AutoSum command by, for example, pressing the Alt+=
keyboard shortcut followed by the Enter key. AutoSum appropriately
determines that the cells containing the values to be used are the three cells
immediately above cell A9 (A6 to A8).
54
Create Excel Macros Without Programming
The keyboard shortcuts I use in the process described above work for English
(United States) language settings. Depending on your language settings, you may
have to use different keyboard shortcuts to achieve the same results.
To confirm that the Macro Recorder has failed to adequately capture the logic
behind AutoSum, do the following:
#2. Execute the recorded macro by pressing the assigned keyboard shortcut
(Ctrl+Shift+A).
Figure 46: The recorded macro fails to identify the appropriate cells to work with.
Notice that the macro fails to reflect the logic behind AutoSum. In other words, the
macro:
• Simply works with the three cells immediately above cell C10 (cells C7 to C9).
This behavior is appropriate when working with the table in column A (which you
used to record the macro and contains three values). However, the behavior is
inappropriate when working with the table in column C (which contains four
values).
55
Create Excel Macros Without Programming
Consider, for example, the two tables (cells A5 to C8 and E5 to H9) displayed in
Figure 47 below. These tables have a different number of rows and columns.
• The first table has three rows and three columns (3x3).
• The second table has four rows and four columns (4x4).
Figure 47: The tables have a different number of rows and columns.
These tables illustrate the inability of the Macro Recorder to adequately capture the
logic behind Excel's Quick Analysis Tool Totals feature.
#1. Enable relative references by clicking the Use Relative References button in
the Developer tab.
56
Create Excel Macros Without Programming
#7. Select the data around the active cell by, for example, pressing the
Ctrl+Shift+* keyboard shortcut.
This keyboard shortcut works for English (United States) language settings.
Depending on your language settings, you may have to use a different keyboard
shortcut to achieve the same result.
Figure 50: While recording the macro: Select the data around the active cell.
Figure 51: While recording the macro: Click Quick Analysis Tool → select Totals → select Sum.
57
Create Excel Macros Without Programming
• Adds the totals below the last row with data; and
Figure 52: The Quick Analysis Tool identifies the appropriate cells to work with.
To confirm that the Macro Recorder has failed to adequately capture the logic
behind the Quick Analysis Tool Totals feature, do the following:
#2. Execute the recorded macro by pressing the assigned keyboard shortcut
(Ctrl+Shift+Q).
In this case, the macro's failure is even more evident than when working with
AutoSum. There are several issues.
Figure 53: The recorded macro fails to identify the appropriate cells to work with.
The main problem with the recorded macro is that it continues to consider a table
with three rows and three columns. This behavior is appropriate when working with
the first table in the worksheet (which you used to record the macro and has three
rows and three columns). However, the behavior is inappropriate when working
with the second table (which has four rows and four columns).
• Overwriting the data in the first three cells of the fourth table row;
58
Create Excel Macros Without Programming
The Ctrl+Arrow Key keyboard shortcut works for English (United States) language
settings. Depending on your language settings, you may have to use a different
keyboard shortcut to achieve the same result.
Consider, for example, the two tables (cells A5 to B10 and D5 to E10) displayed in
Figure 54 below. These tables have the same size. However, a cell in the first
column of the second table (D8) is empty.
Figure 54: The tables are the same size, but the second table contains an empty cell.
These tables illustrate the challenges related to identifying the last row or column
with data in a table or worksheet. This topic is surprisingly complex and exceeds
the scope of this Book.
To understand the limitations of the Macro Recorder when dealing with this type of
situation, record a macro by following these steps:
#1. Enable relative references by clicking the Use Relative References button in
the Developer tab.
59
Create Excel Macros Without Programming
#5. Enter a macro name (for example, "goToLastRow") and assign a keyboard
shortcut (for example, Ctrl+Shift+L).
#7. Press the Ctrl+Down Arrow keyboard shortcut to go to the last row of the
table.
This keyboard shortcut works for English (United States) language settings.
Depending on your language settings, you may have to use a different keyboard
shortcut to achieve the same result.
The applicable keyboard shortcut correctly takes you to the last row of the table
in columns A and B.
60
Create Excel Macros Without Programming
Figure 57: Ctrl+Down Arrow takes you to the bottom edge of the current data region.
To understand the potential pitfalls of this approach for finding the last row with
data, do the following:
#2. Execute the recorded macro by pressing the assigned keyboard shortcut
(Ctrl+Shift+L).
The macro takes you to cell D7. In the case of this table, this is not the last row.
However, since the cell below D7 (D8) is empty, the macro stops here.
Figure 58: The recorded macro does not necessarily take you to the last row.
At a basic level, this gives you access to most of the tools and features in Excel.
These tools and features may cover most of the day-to-day work you (manually)
carry out in Excel.
However, VBA has additional tools and features. You cannot access some of these
manually. Therefore, you cannot use those tools and features in a recorded macro.
In other words, to use those tools and features that help you unleash the full power
of macros, you must use VBA.
61
Create Excel Macros Without Programming
The Table in Figure 59 below lists some examples of such tools and features whose
treatment differs depending on whether you are working manually or with VBA.
Some of these tools and features are more advanced and, therefore, their
consequences may not be completely clear to you right now. I cover (in more detail)
some of these tools and features in Introduction to Excel Macros & VBA.
In any case, this Table may give you an idea of the Macro Recorder's limitations
and the power of VBA.
When you work manually… But when you work with VBA…
You can only work with the object that You can work with objects that are
is currently active or selected. neither active nor selected.
You cannot create macros that receive You can create macros that receive and
or work with arguments. work with arguments.
You cannot work with certain features You can work with certain features or
or settings (for example, very hidden settings (for example, very hidden
sheets). sheets) that are not manually
accessible.
You cannot create custom worksheet You can create custom worksheet
functions. functions (also known as User-Defined
Functions).
62
Create Excel Macros Without Programming
When you work manually… But when you work with VBA…
You cannot create macros with You can create macros with decision-
decision-making capabilities making capabilities. At a basic level,
these macros:
You cannot create macros with loops. You can create macros that, by using
loops, repeat an action (or set of
actions) several times.
You cannot work with user interface You can work with certain user interface
tools and features (for example, tools and features (for example,
message boxes or input boxes). message boxes or input boxes) that are
not manually accessible.
Figure 59: VBA allows you to work with additional tools and features.
How important of an issue this is depends mostly on your objectives. If you just
want to record and use some basic recorded macros, this may not be a problem.
However, as you become a more advanced macro and VBA user, these inefficiencies
in recorded VBA code may become apparent and create challenges.
• Long; and
63
Create Excel Macros Without Programming
• Verbose.
#5. Go to the Page Layout tab in the Ribbon and use the Orientation split button
to select Landscape.
Figure 61: Go to Page Layout → expand the Orientation drop-down → select Landscape.
64
Create Excel Macros Without Programming
This is a very simple macro. However, the Macro Recorder generates the following
code:
Sub setLandscapeOrientation()
'
' setLandscapeOrientation Macro
'
'
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = ""
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.7)
.RightMargin = Application.InchesToPoints(0.7)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
65
Create Excel Macros Without Programming
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
Application.PrintCommunication = True
End Sub
A lot of this code is not necessary to set the page orientation to landscape.
Consider, for example, the following statements:
You can, in fact, identify the line of code that sets the landscape page orientation:
.Orientation = xlLandscape.
The amount of code generated by the Macro Recorder may be puzzling. The Macro
Recorder does this because, when you work with a dialog box, the Macro Recorder
usually considers the complete status of the dialog box.
The macro example above is created by selecting the landscape page orientation
through the Ribbon.
This command, however, is part of the settings in the Page Setup dialog box. When
you set the page orientation to landscape, the Macro Recorder creates code that
regulates virtually every setting in this dialog box. Therefore, settings that do not
66
Create Excel Macros Without Programming
change (for example, headers, footers or margins) are also included in the recorded
VBA code.
Figure 62: When you work with the Page Setup dialog box, the Macro Recorder generates code that regulates all the
settings in the dialog box.
An example of this is copying and pasting. When you manually copy and paste, the
process requires two separate steps:
However, VBA allows you to bypass the Clipboard. In other words, you can tell VBA
to copy an element directly to its destination. Therefore, you can obtain the same
result (copy an item to a destination) in a single step.
• The situations where you probably should not fully rely on the Macro Recorder.
67
Create Excel Macros Without Programming
In any case, you are likely to use the Macro Recorder when learning about, and
working with, macros and VBA. This is particularly the case if you are just beginning
your journey with VBA and have little or no programming experience.
As you become a more experienced VBA user, you may use the Macro Recorder
less frequently. In practice, you are likely to continue using the Macro Recorder
even as an advanced macro and VBA user.
#3. To create basic macros that, later, become the basis of more powerful
macros.
As you learned throughout this Book, the Macro Recorder allows you to create
simple but powerful macros that can:
In practice, the Macro Recorder may meet most of your needs regarding simple
and basic macros. If a basic recorded macro helps you achieve your objectives, you
may not even be interested in how the macro's VBA code looks like.
68
Create Excel Macros Without Programming
The process for using the Macro Recorder as a tool to create an advanced macro
may look, roughly as follows:
#2. Work with, and amend, the VBA code generated by the Macro Recorder to:
• Handle the limitations of the Macro Recorder (several of which you learned
about in previous Sections).
• The Macro Recorder records most, but not all, of your actions.
• The Macro Recorder may fail to adequately capture the logic of certain features,
including:
• AutoSum;
• The keyboard shortcut that takes you to the edge of the current data region.
• The Macro Recorder only records what you can do manually. VBA has several
tools and features you cannot access manually.
• The Macro Recorder tends to generate inefficient code. This may not always
be an issue. However, if you work with the VBA code generated by the Macro
69
Create Excel Macros Without Programming
Recorder, these inefficiencies tend to result in macros that are more difficult to
work with.
• When you work with a dialog box while recording a macro, the Macro Recorder
usually generates code that specifies virtually every setting in the dialog box.
• Despite its limitations, the Macro Recorder continues to be useful for both
beginner and advanced macro and VBA users. The following are three of its main
uses:
#3. To create basic macros that, later, become the basis of more complex
macros.
70
Create Excel Macros Without Programming
Introduction
From time-to-time, you may have to delete macros from your workbooks. There
are several reasons why you may want to do this. The following are two common
reasons for deleting macros:
#1. From Excel, by working with the Macro dialog box. This is the process you
learn in this Chapter.
#2. From the Visual Basic Editor (VBE). You can learn the basics of working with
the VBE, including how to delete macros from the VBE, in Visual Basic Editor
(VBE) Basics.
#1. Go to the Macro dialog box by, for example, pressing the Alt+F8 keyboard
shortcut. This keyboard shortcut works for English (United States) language
settings. Depending on your language settings, you may have to use a different
keyboard shortcut to achieve the same result.
71
Create Excel Macros Without Programming
Figure 63: To delete a macro with the Macro dialog box (steps #1 to #3): Go to the Macro dialog box → select the
macro → click Delete.
#4. Excel displays a dialog box asking you to confirm whether the macro should
be deleted.
Figure 64: To delete a macro with the Macro dialog box (steps #4 and #5): Click Yes to confirm the macro deletion.
• Delete a macro (by working with the Macro dialog box) by following these
steps:
72
Create Excel Macros Without Programming
#4. When Excel displays a dialog box asking you to confirm whether the
macro should be deleted, click the Yes button.
73
Create Excel Macros Without Programming
Next Steps
If you have made it this far into the Book, I hope you have found it useful and
enjoyable.
This Book is accompanied by a website where you can download several files
containing the data and macros used in this Book's examples. The example files
inside the Book's website are organized according to the Chapters and Sections of
this Book. This makes it easy for you to find what you need as you read along.
• Get immediate access to the example files that accompany this Book.
After reading this Book, you probably know how to start creating basic but powerful
Excel macros without programming. This includes, among others:
• What buttons (in the Developer tab) you use when creating macros without
programming.
• How to:
• How to:
• Toggle between using absolute and relative cell references when recording
macros.
74
Create Excel Macros Without Programming
• Why, despite its limitations, the Macro Recorder is useful for both beginner and
advanced Excel macro and VBA users.
Although this Book has ended, our conversation about Excel macros and VBA has
only begun. I am constantly creating training materials to help you become an
Excel Power User.
There are numerous other places we can continue our work together.
You can find my other Books about Excel and VBA (including the other Books in the
Excel Macros for Beginners Series) at Amazon.com.
You can join my Free Course for Excel macro beginners, Introduction to Excel
Macros, by subscribing to the Power Spreadsheets Newsletter.
I also provide a Premium Course for Excel users who have little or no
experience/knowledge about macros or VBA: Excel Macros for Beginners. If you
would like to be the first to know when the doors to Excel Macros for Beginners
open again, you can learn more about the Course and join the waitlist here.
If you have a few seconds, I would love to read what you think about it. As the
reader of this Book, you are my most important reviewer and commentator. I value
your opinion and want to know:
75
Create Excel Macros Without Programming
• Any other wise advice you are willing to share with me.
If you enjoyed this Book, please give it an honest review on Amazon.com. This
helps others learn about Excel macros and VBA, allowing them to become more
efficient and powerful Excel users, positively impacting their own lives and the
broader world.
I:
• Take them into consideration when creating or updating books (such as this
one) or the rest of the training materials at Power Spreadsheets.
Thanks again for your support. I wish you much success with Excel, macros and
VBA. Until next time,
76