+ Reply to Thread
Results 1 to 5 of 5

Sumif function using a variable worksheet name?!

  1. #1
    Registered User
    Join Date
    05-29-2013
    Location
    Brighton, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Sumif function using a variable worksheet name?!

    Hello all, wondered if someone could possibly help with this query?!

    I'm attempting to perform a sumif function referenced to another worksheet...but...the worksheet name referenced in the sumif changes based on a cell reference!

    I've got 12 x data capture sheets called "Capture" 1 through 12 ie Capture 1, Capture 2, Capture 3, etc. (for 12 months of the year)

    The Sumif function is used on one worksheet called "All Filters" but all the formula in this one sheet need to be dictated by a user input (in the setup worksheet) so that data from the correct named capture sheet is pulled and calculated in this same sheet and not 12 different ones!

    The sumif is supposed to calculate the specified range dependant on a cell on a worksheet called "All Filters". This seemed straight forward at first and the formula evaluates to the correct worksheet and range but then ends up as #ref

    The formula i'm using is as follows and i've hammered in quiet a few variants but no joy...please help

    =SUMIF(INDIRECT($A$1& "!$B$2:$B$1000"),'All Filters'!C3,INDIRECT($A$1& "!$C$2:$C$1000"))

    and in cell A1:
    =("Capture "&'Setup'!G33)
    This evaluates to a worksheet name used in the sumif function

    The ref shows as volatile but when I fiddled with it I was able to get it to show as valid but once you evaluate it would then show as #ref

    I've also tried something like this:

    SUMIF("Capture "& Setup!G33 &"!$B$2:$B$1000",'All Filters'!C3,"Capture "& Setup!G33 &"!$C$2:$C$1000")
    This also didn't work :-(

    Please help...

    I hope i've explained this well enough as i'm still a novice

    Many thanks in advance

    Regards

    Keith

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Sumif function using a variable worksheet name?!

    =SUMIF(INDIRECT($A$1& "!$B$2:$B$1000"),'All Filters'!C3,INDIRECT($A$1& "!$C$2:$C$1000"))
    You were pretty close.

    Since the sheet names contain space characters you have to use single quotes around the sheet name.

    =SUMIF(INDIRECT("'"&$A$1&"'!B2:B1000"),'All Filters'!C3,INDIRECT("'"&$A$1&"'!C2:C1000"))

    Quoted ranges in the INDIRECT function will automatically be evaluated as absolute references so there's no need to use the dollar signs $.

    On a side note...

    I was born in New Brighton (Pennsylvania, USA)!
    Last edited by Tony Valko; 07-14-2014 at 09:57 PM.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Sumif function using a variable worksheet name?!

    On the other side of that note, I grew up near New Brighton, (in Port Elizabeth, Eastern Cape, South Africa)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Sumif function using a variable worksheet name?!

    Except for my time in the U.S. Air Force, I've pretty much lived my entire life here in southwestern PA. (not counting all those "road trips" we went on in the 80's!)

    We now return this thread to its regularly scheduled topic!

  5. #5
    Registered User
    Join Date
    05-29-2013
    Location
    Brighton, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Sumif function using a variable worksheet name?!

    I'd imagine those "Brighton's" are way better than the Brighton I'm from...the original UK Brighton on the sunny south coast of England :-)

    Many thanks for the reply I'll let you know how I get on and I've got my fingers crossed as that's been baffling me for a while now!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 09-07-2012, 12:08 AM
  2. Adding variable to specific sheetname in a Sumif function
    By captaincrunch in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 02-04-2010, 12:44 PM
  3. [SOLVED] how to use a variable for the criteria in a sumif function?
    By Dick B. in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-01-2006, 08:00 AM
  4. SUMIF function using Criteria on different worksheet
    By Taxed Mind in forum Excel General
    Replies: 2
    Last Post: 04-14-2006, 09:10 AM
  5. Can I use two criteria in the SUMIF worksheet function?
    By Patricia in forum Excel General
    Replies: 0
    Last Post: 11-02-2005, 06:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1