The OFFSET function can be used to construct dynamic ranges using a starting cell, and given rows, columns, height, and width.
The rows and columns arguments function like "offsets" from the starting reference. The height and width arguments, both optional, determine how many rows and columns the final range includes. We want OFFSET to return a range that begins at the last entry and expands "backwards" so we supply arguments as follows:
reference - the starting reference is D5 – the cell directly to the right of the formula, and the first cell in the range of values we are working with.
rows - we use 0 for the rows argument, because we want to stay in the same row.
columns - for the columns argument, we use the COUNT function to count all values in the range, then subtract 5. This shifts the beginning of the range 5 columns to the left.
height - we use 1 since we want a 1-row range as the final result.
width - we use 5, since we want a final range with 5 columns.
For the formula in C5, OFFSET returns a final range of F5:J5. This goes into the AVERAGE function which returns the average of the 5 values in the range
Less than 5 values
If there are less than 5 values, the formula will return a circular reference error, since the range will extend back into the cell that contains the formula. To prevent this error, you can adapt the formula as follows:
The OFFSET function can be used to construct dynamic rectangular ranges based on a starting reference and given rows, columns, height, and width. The rows and columns arguments function like "offsets" from the starting reference. The height and...
The AVERAGE function will calculate an average of numbers presented in an array, so almost all the work in this formula is to generate an array of the last 3 numeric values in a range. Working from the inside out, the IF function is used to "filter...
The Excel OFFSET function returns a reference to a range constructed with five inputs: (1) a starting point, (2) a row offset, (3) a column offset, (4) a height in rows, (5) a width in columns. OFFSET is handy in formulas that require a dynamic...
The Excel AVERAGE function calculates the average (arithmetic mean) of supplied numbers. AVERAGE can handle up to 255 individual arguments, which can include numbers, cell references, ranges, arrays, and constants.
Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.