Â

Microsoft Excel offers many ways to work with and analyze your data. There are loads of functions to calculate and lookup data, charts to visualize, PivotTables to quickly summarize and much more. TheseÂ features, and more, combine to make Microsoft Excel a very powerful data analytics tool. Using just one of the tools Excel has to offer is great, but Excel really shines when you start combining multiple features together.

Â

BUILDING A DYNAMIC SUM FORMULA

Â

I got an excellent question in my complete Microsoft Excel - Beginner to Advanced course the other day and want to share it with you.

Â

The question asked how you could SUM a dynamic range of cells. There are times when the user wishes to SUM the first 5 cells in a range, other times when the first 7 cells are needed and so on.

Â In the above graphic, the user may want to SUM the first 5 sales amounts, other times the first 7.

Â

We can do this by creating a SUM formula to include all the cells and then modify the formula to include only the cells need.

Â

=SUM(C3:C7)

Â

or

Â

=SUM(C3:C10)

Â

This works, but it involves manipulating the formula and isn't very user friendly.

Â

OFFSET() TO THE RESCUE

Â

Microsoft Excel includes a function called OFFSET().

Â

OFFSET( range, rows, columns, [height], [width] )

Â

Returns a reference to a range that is a specified number of rows and columns from a cell or range of cells. The reference that is returned can be a single cell or a range of cells. You can specify the number of rows and the number of columns to be returned.

Â

The typical SUM formula in an Excel worksheet, SUM's up a range of cells. If you want to change the range you will need to go into the formula and adjust the referenced range.

Â

By combining the SUM function with the OFFSET you can create a dynamic range to be SUM'd.Â This technique of combining functions is called NESTING.

Â

=SUM(OFFSET(C3,0,0,5))

Â

In the above example, the OFFSET() function is NESTED inside of the SUM().

Â

Â

Here, we can inform the SUM function to use the OFFSET function to determine which cells to include in the SUM.

Â

OFFSET(C3, 0, 0, 5)

Â

The above OFFSET informs the SUM function to start with the C3 cell, move 0 ROWS, move 0 COLUMNS, and to include 5 cells starting at C3 and moving down.

Â

Â

Now if the first 7 cells are needed in the SUM, the OFFSET function can be changed from HEIGHT = 5 to HEIGHT = 7.

Â

DOWNLOAD THE EXERCISE FILE TO PRACTICE

Â

Â

Â

Â

Â

Â

Â

Â

Â

Â

Recent Posts

Archive

Tags