Use the OFFSET function to refer to a range, based on a starting cell. For example, get the total sales for April-June (start in column 4, include 3 columns).
The OFFSET function can return a reference to a range. Enter the starting point, number of rows and columns to move from starting point, and how big a range to include (number of rows and columns)
The OFFSET function is volatile, so it could slow down a workbook if used in too many cells.
Instead, you could use a non-volatile function, like INDEX, to return a reference.
The OFFSET function has five arguments: OFFSET(reference,rows,cols,height,width)
With the OFFSET function, you can return a reference to a range, based on a starting reference. In this example, we want the sales amount in cell G2:
In cell H2, there is a similar OFFSET formula, to return the month name. The only difference is the column offset -- 1 instead of zero.
Note: The height and width arguments could be omitted, because we want a reference that is the same size as the starting reference. I used them in this example, to show how all the arguments work.
In this example, the OFFSET function returns a reference to the sales amounts for the selected month, and the SUM function returns the total for that range. In cell B10, the selected month number is 3, so the result is the total of the March sales.
You can also use the OFFSET function to create a dynamic range. In this example, I've created a name, MonthsList, with this formula:
If another month is added to the list in column C, it will automatically appear in the data validation drop down list in cell F2, which uses MonthsList as its source.
In this final example, OFFSET is combined with SUM and COUNT, to show the total for the last n months. As new quantities are added, the formula result will automatically adjust to include the latest months. In cell E2, the number of months is 2, so the August and September amounts are summed.
Download the sample OFFSET workbook
For regular Excel news, tips and videos, please sign up for the Contextures Excel newsletter. Your email address will never be shared with anyone else.
Last updated: September 12, 2016 4:26 PM
Contextures RSS Feed