Home > Articles > Home & Office Computing > Microsoft Applications

  • Print
  • + Share This
This chapter is from the book

Excel Tables and Dynamic Range Names

Before continuing with the topics of journals and ledgers, it's useful to take a detour into the topics of Excel tables and named ranges. The reason is that tables and ranges can help you manage your journals and ledgers (and other data groupings).

Prior to the 2007 version, Excel used what were called lists. A list is not a formal structure such as a pivot table or an embedded chart. It is a way of organizing data that conforms to certain Excel requirements. A list is a rectangular grouping of adjacent cells, with different records (for example, people, accounts, or transactions) in different rows, and with different fields (for example, person's first name, account balance, or transaction date) in different columns. The name of each field is in the list's first row.

There was never an Excel command to insert or build or convert or name a list. However, certain tasks such as building pivot tables and using the built-in Data Form required that basic data layout, and they still do.

Excel 2007 made a formal object of the informal list and called it a table. This creates some confusion with other, different structures such as pivot tables and data tables (the latter are used in so-called "What-If Analysis"), and Microsoft documentation repeatedly warns the reader about that sort of misunderstanding.

Tables in Excel 2007 and 2010 have some capabilities that lists do not:

  • They have formal names: by default, Table1, Table2, and so on. You can change the default name if you want.
  • Their number of rows and columns automatically grows as you add data adjacent to the rightmost column or bottommost row.
  • They have optional total rows, shown at the bottom of the table, that show column statistics such as Sum or Count.
  • Their columns can behave like range names.

For example, if the range A1:E6 in Figure 4.3 were an Excel table named Table1, you could use this formula

=SUM(Table1[Credit])

to get the total of the values in cells E2:E6. If the formula is in a cell that is part of the table, you don't need to use the table name as a qualifier. That is, again in Figure 4.3, this formula would work in a cell in or adjacent to a table in A1:E6:

=SUM([Credit])

If you have a range of data laid out like the data in Figure 4.3, you can convert it to a table in Excel 2007 or 2010. Just select a cell in the range, click the Ribbon's Insert tab, and click Table in the Tables group.

Having done so, you can show the total of the credits in the purchases journal using

=SUM(Table1[Credit])

or, if you've renamed the table, using something like this:

=SUM(PurchaseJournal[Credit])

Notice that the formula works much like using the SUM function with a named range. If the range E2:E6 in Figure 4.3 were named CreditAmounts, you could get the total of those cells with either this:

=SUM(E2:E6)

or this:

=SUM(CreditAmounts)

The basic structure of =SUM(CreditAmounts) is similar to the function as applied to a column in a table: =SUM(Table1[Credit]). But if a range name refers directly and specifically to, say, E2:E6, problems can arise. Those are discussed next.

Building Dynamic Range Names

Each of the first three chapters of this book discussed range names. You have seen how to specify a particular range of cells using a name that you provide: Inventory_Product_Code, for example. Those range names were static. The name always refers to the same set of cells unless you change the address that the name refers to.

Using static range names has several advantages but also some drawbacks. Suppose that you have five values in the range A1:A5. These values represent your company's revenues for the first five months of the year, and you have given the range A1:A5 the name Revenues. Elsewhere on the worksheet, you use the formula =SUM(Revenues) to display your total year-to-date revenues.

At the end of June, you enter June's revenue figure in cell A6. Now, to get the correct result for =SUM(Revenues), you need to click the Formulas tab and select Name Manager in the Defined Names group, and include A6 in the Revenues range (prior to Excel 2007, use Insert, Name, Define).

That's a headache you don't need every month—actually, the real headache is remembering to do it.

Using the OFFSET Function in Dynamic Range Names

What you need is a way to make the name Revenues respond by expanding its own address when you add new values: You need a dynamic range name, not a static one. You can create a dynamic range name by using Excel's OFFSET function. When you define a name, you're not required to enter a specific worksheet address in the Refers To box. You can enter a value or a formula. For example, you could use this formula:

=OFFSET($A$1,0,0,COUNT($A:$A),1)

This formula illustrates the OFFSET function. It returns a reference to a range of cells and contains these arguments:

  • An anchor cell (or range of cells)—In the example, it's one cell: $A$1. The anchor cell informs OFFSET which cell to use as its basis.
  • A Rows argument—In the example, this is the first zero. The reference that OFFSET returns is shifted (or offset) that number of rows from the anchor cell. In this case, the reference is shifted from $A$1 by zero rows.
  • A Columns argument—In the example, this is the second zero. OFFSET shifts the reference by that number of columns from $A$1. Again, this example shifts the reference by zero columns. So far, the OFFSET function is just returning a reference to its own anchor cell, $A$1.
  • A Height argument—In this example, this is COUNT($A:$A). Using the COUNT function informs OFFSET of how many numeric values exist in a range of cells, which is column A in this example. This is the heart of the dynamic range definition. When the number of numeric values in column A changes, it causes COUNT to recalculate. In turn, the OFFSET function recalculates and returns a reference with a different number of rows.
  • A Width argument—In this example, this is the number 1. It defines the number of columns in the range that OFFSET returns.

So this formula returns a reference that depends on the number of numeric values in column A:

=OFFSET($A$1,0,0,COUNT($A:$A),1)

Suppose that column A contains six numbers. The formula returns a reference that is offset from $A$1 by zero rows and zero columns. The reference is six rows high and one column wide. So it returns the reference A1:A6.

As soon as a seventh number is entered in column A, the COUNT and OFFSET functions combine to make the reference one row larger. The reference would then be A1:A7. The name Revenues, defined in this way, is not a static range name, but a dynamic one.

The dynamic range name isn't subject to the drawback to static range names mentioned at the beginning of this section. You no longer need to manually redefine the name Revenues when a new revenue figure is included with the existing values. Your formula =SUM(Revenues) automatically recalculates and returns the sum of all the values in the Revenues range.

One further point: You must keep formulas that refer to the dynamic range outside of that range. Suppose that you put your =SUM(Revenues) formula in column A. The formula gets counted as one of the values that define the extent of the range, which means that the Revenues range in the SUM function is helping to define itself. That's a circular reference error, and Excel won't let you get away with it unscathed—at the very least, you'll need to resolve an error message.

Using Dynamic Range Names in the Journals

The sales and the purchases journals use several dynamic range names. Each range name is sheet level. For example, there is a range named 'Purchases Journal'!Amount and one named 'Sales Journal'!Amount. Each journal has these names and definitions:

  • TransactionDateIn the case of the sales journal, this range refers to the following:
    =OFFSET('Sales Journal'!$A$1,1,0,COUNT('Sales Journal'!$A:$A),1)
  • AccountIt's useful and convenient to make this name, as well as the names Posted and Amount, dependent on the size of the TransactionDate range. On the Sales worksheet, the name Account is defined as follows:
    =OFFSET('Sales Journal'!TransactionDate,0,1)
    The reference it returns is offset from TransactionDate by zero rows and one column. When you do not supply a Height or a Width argument for the OFFSET function, as in this example, it defaults to the Height and Width of the anchor argument. In this case, that corresponds to the TransactionDate range, so the Account reference has as many rows and columns as the TransactionDate.
  • PostedThis name is defined as follows:
    =OFFSET('Sales Journal'!TransactionDate,0,3)

It is offset from TransactionDate by zero rows and three columns.

  • SJDebitsCashThe definition is as follows:
    =OFFSET('Sales Journal'!TransactionDate,0,4)

The name SJDebitsCash uses a naming convention for the journals in the Financial Reports.xlsm workbook: the initials of the sheet name (here, SJ for sales journal), followed by either Debits or Credits, followed by the name of the account that has been debited or credited. The corresponding name in the purchases journal is PJCreditsCash.

The names TransactionDate, Amount, and Posted on the purchases journal use the sheet named 'Purchases Journal' instead of 'Sales Journal' before the exclamation point in the OFFSET function, but they are defined identically otherwise.

Choosing Between Tables and Dynamic Range Names

Both tables and dynamic range names have one particularly valuable advantage over static range names in Excel: They automatically redefine their size when you add new data. That means that if there's another part of the workbook—a chart, for example, or even just a formula—that takes its data from the named range or table, it will automatically update when the table updates or when the range is redefined.

So, how do you decide whether to use a dynamic range name or a table? It's largely a matter of personal preference, and my own is to use dynamic range names. But there's no reason that you should follow my personal preference. Instead, consider the following drawbacks.

If you have more than one column in a table, you need to specify both the table name and the column header that you want to use. For example:

=SUM(SalesJournal[Debits])

whereas if Debits were a dynamic range name, you could use this:

=SUM(Debits)

It's marginally easier for me to remember the name of a range than to remember the name of a table and the field header.

Furthermore, if I use the name of a table in the definition of a charted data series, Excel converts the table name to a worksheet reference. Thus, =SERIES(,,Sheet1!Table3[Credits],1) would get changed to something like =SERIES(,,Sheet1!$D$2:$D$20,1).

However, if you subsequently add data to the table, the charted series definition is updated to show the new data. For example, =SERIES(,,Sheet1!$D$2:$D$20,1) might automatically become something like =SERIES(,,Sheet1!$D$2:$D$25,1).

Dynamic range names have drawbacks, too. A dynamic range name determines the number of rows in the range by using COUNT or COUNTA to get the number of values already present, usually in a column. Therefore, if you have extraneous values in the column, say in A100 when the range you're interested in occupies A1:A20, the COUNT function can easily return one value too many and make the range one row too big.

The other side of that problem is missing values. If you have values in A1:A20 except for one empty cell in, say, A11, the count will be too small by one, and so will the range. This is one reason that I define names such as Debits as offsets from a transaction date range. There will be a transaction date for each transaction, but not necessarily a value in the Debits column for each transaction.

Using tables avoids both these problems at the cost of having to qualify the table's column name by the name of the table itself, and of losing the table name in a chart series definition.

  • + Share This
  • 🔖 Save To Your Account

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020