© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
A. MurrayAdvanced Excel Formulashttps://doi.org/10.1007/978-1-4842-7125-4_3

3. Defined Names

Alan Murray1  
(1)
IPSWICH, UK
 

In Excel, you can define names for ranges, arrays, constants, and formulas.

Most Excel users are familiar with named ranges. The ability to name a range makes our formulas easier to read and write.

However, the technique of defining names in Excel has special powers that many Excel users are unfamiliar with. You will see names being used at various points in this book to overcome Excel limitations.

This comprehensive chapter will cover all the fundamentals of defined names so that when they are used within formulas later in the book, you are well versed in handling them.

We will cover different methods of creating named ranges, how to use them in formulas, and a few tips and tricks for using names in Excel.

We will show how to find and edit existing names and see a basic example of creating a named formula.

Named Ranges

File

named-ranges.xlsx

As mentioned, you can define names for many things in Excel including constants, formulas, arrays, and tables (covered separately in the next chapter). However, when using names, we are often referring to named ranges.

This range can be a single cell, multiple cells, or even an entire row or column.

Why Use Named Ranges?

There are a few reasons why you would use named ranges in Excel:
  • More meaningful references

Using named ranges makes your formulas easier to read and write. Consider a reference to $G$4 vs. CityTax. The reference to CityTax is much simpler and more meaningful than a reference to the grid such as $G$4.

Named ranges can also be unique for an entire workbook. This makes referencing across worksheets simple and concise. They are also absolute by default, so a reference such as 'Master Sheet'!$G$4 can be simplified to CityTax.
  • Faster formula creation

Named ranges appear as you write your formulas, making them faster to type and eliminating the need to click between sheets and scroll on a sheet to locate the cell(s) you want to reference.

We will cover a few tips for your named ranges shortly. These tips will make referencing these named ranges even faster and easier.
  • Easy navigation

Naming ranges makes them easy to find, diagnose, and super quick to navigate to in a workbook. This chapter will show a few techniques to quickly find a named range.
  • Special powers

Named ranges have always had a special power, and this is to link Excel features that cannot work together directly. You will see many examples of this throughout the book.

Define a Named Range with the Name Box

The quickest way to define a named range is to use the Name Box . Let’s see how to do this and then use that name in a formula.

In the previous chapter, we saw the following formula. This IF function uses values from cells F2 and F4 (Figure 3-1):
=IF(B2>=$F$2,B2*(1-$F$4),B2)
Cell F2 is used as the threshold value in the logical test, and cell F4 stores the discount percentage that is used for the value if true behavior.
Figure 3-1

IF function using cell values

Let’s name both input cells to make the formula more meaningful:
  1. 1.

    Click cell F2.

     
  2. 2.

    Click in the Name Box and type “Threshold” (Figure 3-2).

     
  3. 3.

    Press Enter.

     
  4. 4.

    Repeat the steps to name cell F4 as “Discount”.

     
Note

You must press Enter when confirming a name in the Name Box. Pressing Tab or clicking the sheet will not work.

Figure 3-2

Define a name using the Name Box

You can check that the names have been created successfully by clicking the drop-down list arrow on the Name Box . Figure 3-3 shows both names listed along with an existing [lstProducts] name.

If you click a name in the list, it will take you to that named range.
Figure 3-3

Quickly check that the names were created successfully

Using Named Ranges in Formulas

Let’s now replace the cell references in the formula with references to the named ranges.

The easiest way to do this is to type the names when creating or editing a formula. Figure 3-4 shows our two named ranges being entered into the formula.
Figure 3-4

Entering a named range into a formula

As you type the name, a list appears that shows names of functions and ranges. You can identify a named range by the icon to the left of the name.

The following formula is easier to understand than the previous one that used references to the grid:
=IF(B2>=Threshold,B2*(1-Discount),B2)
Note

If you select a range that has been named from within a formula, the named range is returned. However, the grid reference is still understood, and any existing formulas or features that are using the grid reference will continue to work.

You can also insert a named range using a list on the Ribbon. This is especially helpful if you are unsure on the name that was assigned.

From within the formula where you want the name inserted
  1. 1.

    Click FormulasUse in Formula.

     
  2. 2.

    Click the name in the list (Figure 3-5).

     
Figure 3-5

Using a name in a formula from the Ribbon

Another alternative is to press the keyboard shortcut F3. This opens the Paste Name window (Figure 3-6). Select the name to paste and click OK.

This window can also be opened by clicking Paste Names from the Use in Formula list on the Ribbon.
Figure 3-6

Paste Name window in Excel

Rules for Defining Names

There are a few rules to be aware of when defining names in Excel:
  • A name can include numbers, but a name cannot begin with a number.

  • You cannot use spaces in a name.

  • Other invalid characters that cannot be used in a name include the /, &, %, and $. The underscore “_” and period “. ” characters are both allowed.

  • You cannot use a name that has already been assigned, for example, a cell address such as D2 or existing names of ranges, formulas, macros, etc.

  • Names are not case-sensitive. Therefore, the names rngSales, rngsales, and RNGSALES are all the same.

If you try to use a name that already exists, you are taken to that name. Quickly jumping to a range or macro using this method is a cool feature of the Name Box.

If you enter a name using an invalid character, you will see the message shown in Figure 3-7.
Figure 3-7

Message when entering an invalid name

Tips for Defining Names

Here are a few tips when creating a name:
  • Use an underscore “_”, period “. ”, or camel casing as an alternative to a space. For example, I like the camel casing approach and use names such as thisYear. A capital letter is used to denote a word change.

  • Use a prefix for your names. You can use whatever prefix you like, just be consistent. Common prefixes include rng for range, fx for formula, lst for list, and tbl for table (discussed in the next chapter).

Benefits to using prefixes include that you can easily identify the type of name by its prefix, you can use the same name more than once because the prefix is different, and Excel will group them together, making it quick and easy to enter them (Figure 3-8).
Figure 3-8

Named ranges grouped due to the use of a prefix

  • You can also use a consistent suffix to a name.

You want your names to be quick to find and easy to understand. These are only ideas, and you should do what works for you.

Named Ranges with Multiple Cells

Named ranges are not restricted to single cell ranges. A named range can be multiple contiguous cells, a selection of non-contiguous cells, or even an entire row or column.

Continuing with the previous example, let’s name the range of total values from range B2:B8:
  1. 1.

    Select range B2:B8.

     
  2. 2.

    Type “rngTotal” in the Name Box (Figure 3-9).

     
  3. 3.

    Press Enter.

     
Figure 3-9

Define a multicell named range

The formula can now be rewritten to include the [rngTotal] name in place of the reference to the cells in range B2:B8:
=IF(rngTotal>=Threshold,rngTotal*(1-Discount),rngTotal)

Figure 3-10 shows the completed formula. It has spilled to the other cells in range C2:C8, and this is identified by the blue border.

This is a dynamic array, and this behavior will occur if you are using an Excel 2021, Excel for Microsoft 365 (Windows and Mac), or the Excel for the Web version. Dynamic arrays are covered in detail in Chapter 10.
Figure 3-10

Formula spills to the cells below when rngTotal is used

If you are using a non-dynamic array–enabled version of Excel, you will need to fill the formula down the range. It will not spill.

The IF function expects a single value, but multiple values were provided to it when using the [rngTotal] name, so the formula assumed the use of the value in the same row on the grid. This behavior is known as implicit intersection.

As an advanced Excel formula user, it is important to understand this behavior so that we can recognize it on spreadsheets. And there is a case that the formula is more meaningful when using the named range.

However, despite demonstrating this technique, it is not one that I would encourage. A better approach would be to format the range as a table and use the qualities of the table for the formula. Tables are discussed in the next chapter.

Named Range for a Drop-Down List

A common scenario for defining a multicell named range is when using it for the source of a drop-down list .

For this example, we have a list of products that has been named [lstProducts] (Figure 3-11). This can be found on the [Lists] sheet of the provided [named-ranges.xlsx] workbook.
Figure 3-11

Range of cells named lstProducts

On the [Sales] worksheet, there is a SUMIFS function (covered later in the book) in cell F3 returning the total sales for the product entered in cell E3 (Figure 3-12).

We will create a drop-down list in cell E3 to ensure that the data entered is accurate. We will use the [lstProducts] defined name for the source of the list.
Figure 3-12

Sales data with a drop-down list required in cell E3

  1. 1.

    Click cell E3.

     
  2. 2.

    Click DataData Validation.

     
  3. 3.

    From the Settings tab, select List from the Allow list.

     
  4. 4.

    In the Source field, type "=lstProducts" (Figure 3-13). Click OK.

     
Figure 3-13

Named range as the source for a Data Validation list

Note

You can also use the F3 shortcut when in the Source field to open the Paste Name window.

The drop-down list can then be used to easily select the required product (Figure 3-14).

Figure 3-14

Drop-down list of products

Define a Dynamic Named Range

The products’ drop-down list works great, but it is not dynamic. If products are added to the end or removed from the list on the [Lists] sheet, the [rngProducts] name will not automatically adjust in size.

Sure, there are clever techniques around this issue, such as inserting cells in the middle of the range. This forces the named range to adjust its height.

However, this is an advanced Excel formulas book, and it would be great if the named range automatically changed height when products are added or removed.

To do this, we will use the brilliant INDEX function as the source for the named range.

You do not get any assistance when entering a formula into an Excel window, so it is good practice to enter it into a cell first and then copy it into the required window.

The following formula has been entered into cell C2 (Figure 3-15). This uses two INDEX functions; one on either side of the range operator (:). These return the first and last cells in the list and together create the range.
=INDEX(Lists!$A:$A,2):INDEX(Lists!$A:$A,COUNTA(Lists!$A:$A))
Figure 3-15

INDEX formula to create a dynamic range

The first INDEX function returns the address of the cell in row 2 of column A. Row 2 is entered as a constant value. In the second INDEX function, the COUNTA function is used to count the number of non-blank cells in column A. In this example, it successfully returns the address of the final non-blank cell.

Note

The INDEX function is covered in depth in Chapter 11. If you are new to this function, you can jump to that chapter for an explanation on how this formula works.

I am using an Excel for Microsoft 365 version, so the values from the range are returned and spilled to the grid. You will not see this if you are using an older version of Excel; however, the formula works, so proceed with the next steps:
  1. 1.

    Copy the formula from the Formula Bar.

     
  2. 2.

    Click FormulasName Manager.

     
  3. 3.

    Select the lstProducts name and click Edit (Figure 3-16).

     
Figure 3-16

Edit an existing named range

  1. 4.

    Delete the contents of the Refers to field and paste in the formula (Figure 3-17). Click OK.

     
Figure 3-17

Pasting the formula as the range for the defined name

When new products are added to the end of the list, they are automatically included in the drop-down list.

Figure 3-18 shows “Orange Juice” added to the end of the list. This list can then be sorted in A-Z order.
Figure 3-18

Adding a new product to the end of the list

Figure 3-19 shows “Orange Juice” in the drop-down list after it was added to the source list on the [Lists] sheet, and the products were sorted in A-Z order.
Figure 3-19

Range automatically adjusts to include new products

Note

Dynamic named ranges can also be created using a combination of tables and named ranges. We show an example of this in the next chapter.

Define Names with Create from Selection

Another way to create named ranges is to use the Create from Selection option. This is great for creating multiple named ranges at once.

In this example, we have the data shown in Figure 3-20. We have three levels that each apply a different discount.

We will name the cells in ranges G3, G4, and G5 using the values in the cells to their left (F3, F4, and F5). Then use a SWITCH function to subtract the necessary discount in column D.
Figure 3-20

Data containing the level and discount to apply

Note

The discount’s range is on the same sheet to simplify the example. Named ranges default to having a workbook scope, so they are just as easy to access on other worksheets. That is another great strength of using them.

  1. 1.

    Select range F3:G5.

     
  2. 2.

    Click FormulasCreate from Selection or press Ctrl + Shift F3.

     
  3. 3.

    The Create Names from Selection window appears and guesses where the values you want to use for the names are (Figure 3-21). Very often, this is correct, but you should check. Left column is selected in our example. This is correct. Click OK.

     
Figure 3-21

Create multiple names at once with Create from Selection

This creates three named rangesGold, Silver, and Bronze. Faster than creating them individually.
  1. 4.

    The following SWITCH function can be entered into cell D2 and filled down (Figure 3-22):

     
=C2*SWITCH(B2,"Gold",(1-Gold),"Silver",(1-Silver),"Bronze",(1-Bronze))
Figure 3-22

SWITCH function to apply the correct discount

The SWITCH function checks the level in column B against its list of values and returns the matching discount to be applied to the amount.

Scope of a Defined Name

The scope of a defined name is the location and general accessibility of the name. A name can either have workbook scope or worksheet scope:
  • Workbook: The name is available to all sheets of a workbook. The name is unique across all sheets of the workbook and can easily be referenced using its name.

  • Worksheet: The name is only unique and easily accessible within that specific worksheet.

The default scope of a named range is the workbook level, and all the names created so far in this chapter have had that scope.

Note

You can reference names with a worksheet scope from other sheets by preceding its name with the sheet name, for example, Sheet3!TotalSales. However, this is not encouraged, and the name should have been given workbook scope.

Let’s look at how to create a named range with worksheet scope.

We have the data shown in Figure 3-23, with the following IF function in column C that calculates a 15% discount if the target in cell E3 is reached:
=IF(B2>=$E$3,B2*(1-15%),B2)
Figure 3-23

IF function to apply discount if target is reached

We will create a named range for cell E3 with worksheet-level scope:
  1. 1.

    Click cell E3.

     
  2. 2.

    Click FormulasDefine Name.

     
  3. 3.

    In the New Name window (Figure 3-24), change the Name to “rngTarget”.

     
  4. 4.

    Change the Scope using the drop-down list provided from Workbook to Scope and Constants (this is the name of the worksheet). Click OK.

     
Figure 3-24

Creating a new name with worksheet-level scope

The rngTarget name can now be used instead of the $E$3 reference in the IF function (Figure 3-25). However, if you try and reference rngTarget from another worksheet, it will not be recognized.
Figure 3-25

Using rngTarget in the IF function

You cannot edit the scope of an existing named range. Figure 3-26 shows the Edit Name window and the scope option disabled.
Figure 3-26

Scope option disabled when editing a named range

It is worth noting the behavior of names when sheets are copied in Excel. The behavior is often undesirable causing confusion and cluttered workbooks. Therefore, it is important to be familiar and understanding of what happens when sheets are copied.

The following lists the general behavior of names when sheets are copied within the same workbook or to another workbook:
  • When a worksheet with a workbook scope named range is duplicated within the same workbook, a second name with the same name but worksheet level scope is created.

    Figure 3-27 shows two [Discount] and [Threshold] names caused by copying the [Named Ranges] worksheet. These new names have worksheet scope. This is shown in the [Scope] column of the Name Manager window. The name of the duplicated worksheet [Named Ranges (2)] is shown.

Figure 3-27

Copied sheet creating duplicated names with worksheet scope

  • When a worksheet with a named range is copied to another Excel workbook, the name is copied along with the sheet. This applies to both workbook and worksheet scope named ranges.

    This is generally a good action as you probably require the named range in that workbook too. However, it is important to be aware of this behavior; otherwise, Excel files can get cluttered quickly with redundant names.

  • When a workbook contains a named formula with workbook scope, and a worksheet is copied to another workbook, the named formula is also copied to the other workbook. However, the named formula links back to the workbook from which it was copied.

    Figure 3-28 shows the [lstproducts] name that we created using the INDEX formula. A worksheet was copied to another workbook, and this named formula was copied with it, but links back to the [named-ranges.xlsx] workbook.

    This behavior is bad. Be careful of external links in a workbook that are generated by users copying sheets to the workbook. This only happens with workbook scope names.

Figure 3-28

External link caused by copying a name to another workbook

Note

In Chapter 15, when LAMBDA functions are discussed, we will use the technique of copying ranges that contain formulas as a simple method to copy our custom named formulas to other workbooks.

Define a Named Constant

In addition to naming ranges, it is also possible to name constants. As its name suggests, a constant is a value that does not change, unless the named constant is edited.

So, it is not necessary to have a value on the worksheet to be able to assign a name to it.

This can help to free your worksheet from unnecessary clutter while enabling the ability to use meaningful names for values.

In a previous example, the following formula was used to apply a discount if a specified condition was met. A 15% discount is applied and is written into the formula:
=IF(B2>=rngTarget,B2*(1-15%),B2)
Let’s create a named constant for that discount value:
  1. 1.

    Click FormulasDefine Name.

     
  2. 2.

    In the Name field, enter “cstDiscount” (Figure 3-29).

     
  3. 3.

    In the Refers to field, enter “=0.15”. Click OK.

     
Figure 3-29

Creating a named constant

Note

The prefix cst has been used in the name to easily identify it as a constant. Remember, prefixes are optional, and you can use whatever you want. Other common prefixes for constants include const and k.

This named constant can now be used in the formula instead of typing 15% (Figure 3-30).

This constant has workbook scope. So, if the constant were changed to a different percentage in the future, all formulas that reference it would update.

This is more efficient than changing the percentage directly in all formulas it was written into.
Figure 3-30

Using a named constant in a formula

Finding Named Ranges

There are a few different methods to easily find and jump to a named range in Excel:
  • Using the Name Box

The Name Box provides a quick no-nonsense method of jumping to a named range. Click the list arrow on the end of the Name Box to list the named ranges in the current scope. Click a name to jump to that selected range.

Figure 3-31 shows the Name Box list activated from the [Lists] sheet. It lists the named ranges that we have created so far in this chapter. However, you may notice some absentees:
  • cstDiscount: It only lists named ranges, so named constants will not appear in the list.

  • lstProducts: This name is the dynamic named range created earlier using the INDEX formula. Names that use a formula as their source are not shown in the Name Box list.

  • rngTarget: This name was created from the [Scope and Constants] worksheet with worksheet-level scope. Therefore, it is not visible from the Name Box list on the [Lists] sheet.

Figure 3-31

Using the Name Box to find named ranges

You can also navigate to these names by typing their names into the Name Box. This includes those that use a formula as their source such as [lstProducts].

This applies to grid references too. So, if you type D10000 into the Name Box and press Enter, you are taken to cell D10000. If you type A1 and press Enter, you are taken back to A1.

You can even take this further and enter ranges such as B2:D10 to select that range. You can include the sheet name in the range such as Sheet3!B2:D10. You can even enter R1C1 references such as R1C19 to jump to row 1 column 19.

Some of these tricks are not every day useful, but they are pretty cool, and you never know when they may come in handy.
  • The Go To window

The Go To window provides another fast way to jump to a named range from anywhere within its scope.

Press F5 on the keyboard to open the Go To window (Figure 3-32). Select the name you want to go to and click OK.

Note

You can also open the Go To window by pressing the Ctrl + G shortcut or by clicking Home ➤ Find & Select ➤ Go To.

Figure 3-32

The Go To window listing named ranges

Just like the Name Box, the Go To window only lists the names that are from a range. So, names that use a formula for their source, such as [lstProducts], are not listed.

Once you have followed a name, you can return to the previously active range quickly by pressing F5 and then Enter.

This keyboard combination works because on following a range, the previously active range is listed first in the Go To window (Figure 3-33).
Figure 3-33

Previous range listed in the Go To window

Relative Named Ranges

Named ranges are absolute by default. And this makes sense as you are defining a specific area in the workbook.

However, it is possible to create relative named ranges in Excel. Let’s see an example of how and why you would want to do this.

In Figure 3-34, the following formula has been entered in cell C3 and filled down. This formula calculates the percentage change between the current month and the previous month:
=(B3-B2)/B2
Figure 3-34

Month on month percent change

In this example, we will define names for both the cells used in the formula (B2 and B3). These references will be made relative so that when the formula is filled down, it uses the correct cells in context to the month:
  1. 1.

    Click cell C3.

     
  2. 2.

    Click FormulasDefine Name.

     
  3. 3.

    Enter “PrevMonth” as the Name for the range (Figure 3-35).

     
  4. 4.

    Change the Scope to the worksheet. The worksheet we are using is named Relative Named Range . I do not want this name appearing on other sheets.

     
  5. 5.

    Enter a descriptive comment such as “Refers to the cell one row above and one column to the left.” In this example, I do not think the name is descriptive enough and a comment is required.

     
  6. 6.

    In the Refers to field, change the cell on the end of the reference from $C$3 to B2. Click OK.

     
Figure 3-35

Relative named range for the previous month

Let’s create another relative named range for the current month’s value:
  1. 1.

    From cell C3, click FormulasDefine Name.

     
  2. 2.

    Enter “CurrentMonth” for the Name (Figure 3-36).

     
  3. 3.

    Set the Scope to the current worksheet Relative Named Range .

     
  4. 4.

    Enter a descriptive comment such as “Refers to the cell in the current row and one column to the left.”

     
  5. 5.

    In the Refers to field, change the cell on the end of the reference from $C$3 to B3. Click OK.

     
Figure 3-36

Relative named range for the current month

With both named ranges set up, we can now edit the formula to use them. Figure 3-37 shows the updated formula with C6 as the active cell. This shows the formula working perfectly, and it is more descriptive with the named ranges.
Figure 3-37

Percent change formula using the relative named ranges

Named Formulas

In addition to naming ranges and constants in Excel, you can also create named formulas. We have actually already done an example of this – the dynamic named range using the INDEX function.

Now, that formula returned a range, so it was really still a named range. Let’s see an example of a named formula that returns a value.

On the [Lists] worksheet, we have a list of products (Figure 3-38).
Figure 3-38

List of products

We want to return a count of the products so that we can use that result within other formulas in Excel.

Instead of writing a formula to return the result to the grid, we will write it in the Refers to field when defining a name:
  1. 1.

    Click any cell of the worksheet and enter the following formula. It is easier to write a formula in a cell first.

     
=COUNTA(Lists!$A:$A)-1
  1. 2.

    Copy the formula text.

     
  2. 3.

    Click FormulasDefine Name.

     
  3. 4.

    Enter “fCountProducts” as the Name for the formula (Figure 3-39).

     
  4. 5.

    Paste the formula into the Refers to field and click OK.

     
Figure 3-39

Defining a named formula for count of products

  1. 6.

    The formula can now be deleted from the cell it was written in.

     

This name can now be used in a cell, or within another formula, to always return the count of products.

This name was created with workbook scope, so it can be referenced easily from any worksheet (Figure 3-40).
Figure 3-40

Using the named formula in a cell

Note

We will see more advanced examples of naming formulas in Chapter 15, when we explore the LET and LAMBDA functions of Excel.

Managing Names

The Name Manager in Excel makes it super simple to find, review, edit, and delete your names.

To open the Name Manager, click FormulasName Manager or press Ctrl + F3.

The Name Manager lists all the names in the workbook (Figure 3-41). This includes the constants, tables, and named formulas.

It displays the current value (if possible) and shows what the name refers to and the scope of the name. Everything you need to know about a name is here. It truly is the name manager.

Edit a Name

Let’s edit the [Threshold] name that we created at the beginning of the chapter. We want to make a simple edit to include the “rng” prefix in front of its name:
  1. 1.
    From the Name Manager, select the “Threshold” name and click Edit at the top of the window (Figure 3-41).
    Figure 3-41

    Editing a name in the Name Manager

     
  1. 2.

    Edit the Name to read “rngThreshold” (Figure 3-42). Click OK.

    Note You can also edit the Refers to and Comment fields, but note that the Scope of a name cannot be changed.

     
Figure 3-42

Editing a name

All formulas that reference the name [Threshold] will automatically update to reference [rngThreshold].

Filtering Names

The Name Manager provides an excellent filter – very useful if you have many names.

For example, you can filter for only names with workbook scope, or only the defined names and ignore the tables, or filter to only show names that have errors.

Figure 3-43 shows three of the names displaying the #REF! error. This is caused because the data that the names were using has been removed.

Click Filter in the top-right corner and click Names with Errors to only show these names.
Figure 3-43

Filtering names in the Name Manager

When the names have been fixed, or you just want to return to seeing all the names, click FilterClear Filter (Figure 3-44).
Figure 3-44

Clear a filter from the Name Manager

Print a List of the Names

You can also print a list of the names to the worksheet. This feature will only print names that have workbook scope.

Let’s print the names to cell A2 of the [Print Names] worksheet:
  1. 1.

    Click cell A2.

     
  2. 2.

    Click FormulasUse in FormulaPaste Names or press F3.

     
  3. 3.

    Click the Paste List button (Figure 3-45).

     
Figure 3-45

Paste list of names

The list of names is printed, including what they refer to (Figure 3-46).
Figure 3-46

List of names and what they refer to

Note

This list is not dynamic and therefore will not update when names are added, removed, or changed.

Apply Names to Existing Formulas

If you define names after using them within formulas, there is a neat way to update these formulas with the names.

Let’s use an example with the formula we used in the “Define Names with Create from Selection” section of this chapter.

The formula is shown in Figure 3-47, but it uses grid references and not the names that we defined for cells G3, G4, and G5.
=C2*SWITCH(B2,"Gold",(1-$G$3),"Silver",(1-$G$4),"Bronze",(1-$G$5))
Figure 3-47

SWITCH function using grid references

To update the formulas with the names
  1. 1.

    Click Formulas ➤ list arrow next to Define NameApply Names (Figure 3-48).

     
Figure 3-48

Apply names to existing formulas with grid references

  1. 2.

    Click the Bronze, Gold, and Silver names. Click OK (Figure 3-49).

    Note The names will be applied to all formulas where they can match the name and grid reference in the entire worksheet.

     
Figure 3-49

Applying names to a worksheet

The Ignore Relative/Absolute option ensures that the name and grid are an exact match. If the grid reference is relative, but the named range is absolute, it will be ignored.

This is preferable, so we leave it checked. Changing relative references to absolute and vice versa at large scale does not sound good.

Summary

This chapter has provided a comprehensive understanding of defining names in Excel. We have covered the creation, application, and best practice of named ranges, formulas, and constants. We also saw how to work with existing names in an Excel workbook and how to find and manage the different types of names.

We will see names throughout this book. They will be used in different moments to simplify our formulas and to achieve tasks that would be difficult or not even possible without them.

In the next chapter, we will explore tables in Excel. Tables provide a way for us to work with structured data easier. They enable us to work beyond the grid and make referencing and analyzing Excel data more meaningful and simpler. Tables have been mentioned a few times in this chapter as they are also a named item and appear in the Name Manager. This makes tables a logical chapter to succeed the topic of defined names.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.130.201