Creating automatically extended plot ranges

Excel 2016 2013 2010 2007 2003
If you often need to adjust your data ranges so that your charts plot an updated data range, you may be interested in a trick that forces Excel to update the chart's data range whenever you add new data to your worksheet.
Chart in Excel 365
The Chart with automatically extended plot ranges in Excel 365

To force Excel to update your chart automatically when you add new data, follow these steps:

   1.   On the Formulas tab, in the Defined Names group, click Define Name:

Define Name in Excel 365

   2.   In the New Name dialog box:

  • In the Name field, enter Data,
  • In the Refers to field, enter this formula:

    OFFSET (<Sheet name>!<start cell>, 0, 0, COUNTA (<Sheet name>!<Column name>: <Column name>) - 1)

    New name in Excel 365

    The OFFSET function returns a cell or range of cells that is a specified number of rows and columns from a cell or range of cells:

    OFFSET (<reference>, <row>, <column>, [height], [width])

    Note: How to use the range from row instead of column, see below in the tip.

  • Click OK.

Notice that the OFFSET function refers to the first data point (cell B5) and uses the COUNTA function to get the number of data points in the column.

   3.   Define a new data range, in the New Name dialog box:

  • In the Name field, type Sales,
  • In the Refers to field, enter the appropriate formula for Sales data:
    New name in Excel 365
  • Click OK to close the dialog box.

   4.   Create the chart.

   5.   Change the range of data series and axis with the names that you defined in Steps 2 and 3:

  • Series values: <Excel-file name>!Sales
    Series in Excel 365
  • Axis label range: <Excel-file name>!Data
    Axis label in Excel 365

After you perform these steps, when you add data to columns B and C, the chart updates automatically to show the new data (see on the top of this screen). To use this technique for your own data, make sure that the first argument for the OFFSET function refers to the first data point, and that the argument for COUNTA refers to the entire column of data. Also, if the columns used for the data contain any other entries, COUNTA will return an incorrect value.

Notes:

  1. At the moment, the secondary axes don't change dynamically, depending on the data.
  2. In this example, the COUNTA formula was used to avoid counting blank cells.

    Cells with formulas or filled with irrelevant information such as comments will also be counted as non-empty.

    In this case, it is necessary to replace the COUNTA formula by another one. For example:

    • COUNT will count only cells with numbers, but it also has issues depending on the formula. In some cases, the COUNT formula can calculate some formula results that you don't want to show in the chart.
    • COUNTIF will count cells that contain numbers. For example:

      COUNTIF (<data range>, ">0").

  3. If you need to use the data from rows instead of columns, change the formula code to:

    OFFSET (<Sheet name>!<start cell>, 0, 0, 1, COUNTA (<Sheet name>!<Row name>: <Row name>) - 1):

    Chart in Excel 365
    The Chart with automatically extended plot ranges in Excel 365

See also this tip in French: Comment créer les graphiques avec les plages de tracé étendues automatiquement.

If you have any questions or suggestions, please feel free to ask OfficeToolTips team.