• RyanDev.com

  • How to use a dynamic sheet name in an Excel formula

5th November 2008

How to use a dynamic sheet name in an Excel formula

posted in Microsoft Excel |

Sometimes when writing a complex formula you may not know which sheet of data you want the value to come from.  Or, maybe the sheet will change based on some conditions.  This is easy to accomplish.

For example, the following formula will return the value in cell A1 of whichever sheet is typed into cell B1. 

=INDIRECT(ADDRESS(1,1,,,B1))

The INDIRECT function can be used for many useful dynamically determined values.  In this case, the Address function will return the full address of the cell you are looking for based on the current workbook.  So, if ”Sheet2″ is typed into cell B1, ADDRESS(1,1,,,B1) = Sheet2!$A$1.  If the value in cell B1 were changed to “JanuarySales” the value returned by the Address function would be JanuarySales!$A$1.

The power is in the Indirect function.  Indirect will return the value of the cell that you are passing into the function.  So, Indirect(”Sheet2!$A$1″) will return the value that is in cell A1 on Sheet2.

The wonderful power of Excel is that any of the parameters can be specified with other functions.  Maybe you need to use an If statement to properly determine which sheet to pull from.  =INDIRECT(ADDRESS(1,1,,,If(Month(Now())=1,”JanuarySales”,”FebruarySales”)))

This entry was posted on Wednesday, November 5th, 2008 at 2:13 am and is filed under Microsoft Excel. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

There are currently 16 responses to “How to use a dynamic sheet name in an Excel formula”

Why not let us know what you think by adding your own comment! Your opinion is as valid as anyone elses, so come on... let us know what you think.

  1. 1 On August 25th, 2009, Suman said:

    Thanks for the help. I broke my head figuring out this for so many days, you have solved it in a second.

  2. 2 On October 29th, 2009, acomplal said:

    Very nice site! Thanks for sharing!

  3. 3 On November 2nd, 2009, ammyka said:

    Very nice site! Thanks for adding the links. Thanks for sharing!

  4. 4 On November 3rd, 2009, aleqder said:

    This is fantastic! Very nice site! good job!

  5. 5 On November 8th, 2009, acazdia said:

    Thanks for adding the links. Very nice site!

  6. 6 On February 15th, 2010, Jay S. said:

    Hi, nice and intersting site.

  7. 7 On May 21st, 2010, student loans said:

    Terrific work! This is the type of information that should be shared around the web. Shame on the search engines for not positioning this post higher!

  8. 8 On June 14th, 2010, free government grants said:

    I’ve recently started a blog, the information you provide on this site has helped me tremendously. Thank you for all of your time & work.

  9. 9 On June 29th, 2010, ultrasound technician said:

    Great information! I’ve been looking for something like this for a while now. Thanks!

  10. 10 On August 27th, 2010, sample resume said:

    amazing post, greatly informative!

  11. 11 On September 25th, 2010, veterinary technician said:

    Valuable info. Lucky me I found your site by accident, I bookmarked it.

  12. 12 On November 13th, 2010, Buy said:

    Trackback…

    […] I found your entry interesting thus I’ve added a Trackback. […]…

  13. 13 On November 29th, 2010, maria andro said:

    I really liked your blog! It helped me alot…

  14. 14 On December 14th, 2010, USans said:

    Trackback…

    […] I found your entry interesting thus I’ve added a Trackback. […]…

  15. 15 On December 17th, 2010, Daniel said:

    great post, thanks for sharing

  16. 16 On April 1st, 2011, Tom Mcdavid said:

    Well done, thanks for the great post.

Leave a Reply

  • Links

  • Calendar

  • February 2012
    S M T W T F S
    « Jan    
     1234
    567891011
    12131415161718
    19202122232425
    26272829