Post image for Excel OFFSET Function Explained

Excel OFFSET Function Explained

by on November 24, 2010

in Excel,Microsoft Office Training,Online Training

The OFFSET function is one of Excel’s best kept secrets.  Probably because it’s quite tricky to explain, and can be confusing to understand. 

So, in this tutorial I’m going to do my best to keep it simple so you can get your head around it and then I’ll cover a few of the most useful ways I find to use OFFSET.

Download the workbook and practice what you learn, or reverse engineer the formulas for deeper understanding.

First here’s the technical explanation for the OFFSET function.

Skip this if you want, but I know some of you will want to know it too.

The Excel OFFSET function returns a cell or range of cells that are a specified number of rows and columns from the original cell or range of cells.

The Excel syntax for the OFFSET function is:

=OFFSET(reference,rows,columns,height,width)

What the?  That’s what I thought when I first stumbled across OFFSET.

Here’s an easy way to think about it.  I liken it to a treasure map (an easy one my 4 year old son could follow).  The spot marked ‘X’ can either be a single cell or a range of cells (more on this later).

In our example let’s say our starting point is cell A1 and the spot marked ‘X’ is cell D5.

how excel offset formula works

So in treasure map speak our OFFSET function would read:

=OFFSET(starting at A1, step down 4 rows (you’ll be in cell A5), then step across 3 columns (you’ll be in cell D5), Including cell D5 you’ll find the treasure in a range that’s 1 cell high, and one cell wide i.e. cell D5 )

This is how our treasure map function would read in Excel =OFFSET(A1,4,3,1,1)

Let’s break down the OFFSET function components:

=OFFSET(reference,rows,columns,height,width)

1)      The reference is the starting point in your treasure map/worksheet.

2)      Rows are the number of rows you want Excel to move from the starting point.

3)      Columns are the number of columns you want Excel to move from the starting point.

4)      Height is the number of rows ‘X’ occupies, in our example it’s 1.

5)      Width is the number of columns ‘X’ occupies, in our example it’s 1.

That’s all good and well, but I can’t think of any pirates who are likely to be using Excel for their treasure maps, so what else is it good for?

Hold up, let’s walk before we run.

Things you should know about OFFSET

  • You can enter the OFFSET formula in any cell, except of course the cell/cells where ‘X’ is.  In the above example our formula is in cell A7.  Although OFFSET in this example returns the value in cell A7, it isn’t actually designed to use on its own, but because in this example we’re asking OFFSET to only return 1 cell, it returns the value in the cell.  If we asked it to return a range of cells it would return an error.

  • The reference can be a single cell or a range of cells, likewise the result OFFSET returns
  • The height and width arguments are optional, if you don’t enter a height and width OFFSET will return a range that is the same height and width as the reference.

OFFSET Function Examples

offset reference single cell
offset reference range of cells
offset reference range of cells no height & width
offset reference single cell - rows

Practical Uses for Excel’s OFFSET Function

1) Create a Dynamic SUM Formula

How often do you have to update the range of a SUM formula because you’ve added a row just above the SUM and it hasn’t automatically picked it up?  If you’re like me it’s all the time.  Here’s how I use OFFSET to save time by making my SUM formulas dynamic.

In the table below I have Totals in row 56.  In cell D56 my SUM formula using OFFSET would look like this: =SUM(D45:(OFFSET(D56,-1,0)))

dynamic sum using offset function

2) Use OFFSET and MATCH functions together with SUM and MAX

There are a few things going on in the example below:

I.  Just to make it a bit fancy and link to a previous tutorial, in Cell B61 there is a drop down list or data validation list as they’re called in Excel. 

By changing the selection in cell B61 my formulas in cells B62 and B63 dynamically change to give the SUM of the viewers for the selected program and the MAX viewers.

Since I already covered SUM with OFFSET above, I’m just going to cover the OFFSET and MATCH section of the formula in the example below.

offset with match function

II. Working through the ‘Sum of Viewers’ formula, the reference cell for the OFFSET function is B65, i.e. the junction of the table.

III.We then use the MATCH function to find the row that Ben Ten is on from the range B66:B72, with row 66 being 1, row 67 being 2 etc. This result is then used to instruct the OFFSET function how many rows from B65 Ben Ten is on.  In this case it is 2.

IV.We then use 1 as the number of columns so that the start of the SUM is from column C.

V.  The number of rows in our range we want summed is 1

VI. The number of columns in our range we want summed is 4.

VII. The MAX and MIN formulas for the Highest and Lowest Viewers works in the same way, only instead of SUM we used MAX and MIN.

3)      SUM COUNT and OFFSET

Being an accountant I like to double check everything.  For example, when working with tables that have totals on columns and rows I like to have a ‘Control’ total that cross checks to make sure the totals add up correctly.  My ‘Control’ total should always come back to 0 to indicate there is no discrepancy.  Like in the example below in column G, I usually colour the font grey as it’s something that isn’t part of my analysis or anything that I want to print.

offset with count and sum

The control formula in cell G86 is =SUM(OFFSET($A$78,1,1,COUNT($B$79:OFFSET($B$86,-1,0,1,1)),4))-F86

Sure I could have just used =SUM(B79:E85)-F86 which works too. But if I keep adding rows or columns to my table I have to alter my SUM control formula too.

Let me explain how this works.

I use the SUM to add the figures in the body of the table, and I use the OFFSET and COUNT to tell me what the range is.  Should I ever add any rows to the table, my Control formula will automatically pick them up.

i)   OFFSET($A$78,1,1 is telling Excel to start my SUM from cell B79.

ii)   COUNT($B$79:OFFSET($B$86,-1,0,1,1)) is telling Excel how many rows in my range

iii)  ,4)) is telling Excel how many columns in my range.  I could have used another COUNT OFFSET combination like I did above to calculate the number of rows in my range, but since I’m confident I’ll only ever have 4 regions (East, North, South and West) I’m happy to leave this hard coded at 4 columns

iv)  –F86 is simply making sure the total of my Control is equal to the total of the table in cell F86.  It’s quicker and easier to check Controls equal 0 than comparing two numbers visually to make sure they match.

Like many Excel formulas, on its own OFFSET isn’t much use, but team it up with other formulas and it’s a winner.

How do you use OFFSET? Share your knowlege in the comments below.

Share the knowlege with your friends and colleagues. Click the icons below for Twitter, Facebook, Stumbleupon and many more.

FREE PDF Download
100 Excel Tips & Tricks

Excel Tips & Tricks E-Book
Just enter your details below

Leave a Comment

{ 7 comments… read them below or add one }

Ramesh May 29, 2011 at 3:46 am

Excellent material . Thanks a lot for sharing. offset is truly a great function.

Reply

Karine Bouffard March 30, 2012 at 12:35 am

Hi Mynda,
When I try to download the workbook at the top of the page I get some strange files but no zip containing excel file. Can you please have a look if something got corrupted? Thanks a lot.
Karine

Reply

Mynda Treacy March 30, 2012 at 6:09 am

Hi Karine,

The workbook is not zipped. It’s a .xlsx file. If you hover your mouse over the link you can see the file name ends in a .xlsx extension (usually in the bottom right or left of your browser window).

Some browsers assume files are zipped and change the file extension when you try to download them. Just make sure the file extension is a .xlsx file when you download it. You can simply type over the .zip extension with .xlsx to fix the problem while in the ‘file save as’ or similar dialog box.

I hope that makes sense. Let me know if not.

Kind regards,

Mynda.

Reply

Imran March 30, 2012 at 10:00 pm

Awesome explaination.. Thanks

Reply

Mynda Treacy April 3, 2012 at 3:09 am

Cheers, Imran.

Reply

Meshark May 3, 2012 at 7:21 pm

Excellent material, very brilliant delivery. First time user of your site. Just downloaded the excel blog file. Thanks a million times for your effort and time. I desire to be an awesome excel user. Not yet close but would work hard with you as my guide. Thank you once again.

Reply

Mynda Treacy May 3, 2012 at 8:40 pm

Hi Meshark,

Thanks for your kind comments. I’m glad you like our site :)

Kind regards,

Mynda.

Reply

Previous post:

Next post: