+ Reply to Thread
Results 1 to 13 of 13

using INDEX and MACTH in a SUMIF formula

  1. #1
    Forum Contributor
    Join Date
    11-18-2014
    Location
    England
    MS-Off Ver
    365
    Posts
    132

    using INDEX and MACTH in a SUMIF formula

    Hi I have a spreadsheet which has data on one tab and lookups on another tab. I want to create a dynamic sumif formula so when I change the week number in one cell on the lookup sheet the sumif automatically looks for that week in the data and totals it. I also need to use the staff members name as a criteria. The tab. I have attached an example of the table and the data (sheet 1 and 2). I basically want the dynamic sum if in cell B8 to say if you see this header in the table on the data sheet and this area manager in column D on the data sheet then add everything up. I have tried to incorporate INDEX and MATCH to make this work but I can't get it to show a result. PLEASE HELP!
    Attached Files Attached Files

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,443

    Re: using INDEX and MACTH in a SUMIF formula

    Hello,

    You could use something like this

    =SUMIF(Sheet2!$D$4:$D$30,Sheet1!$A8,OFFSET(Sheet2!A4:A30,0,MATCH(B$7,Sheet2!$3:$3,0)-1))

    in B8. However, there are currently logical differences between the contents of B7 and the apparently matching cell in Sheet2 row 3. I imagine that this is because there are hard carriage returns, or other such non-printing characters present.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Forum Contributor
    Join Date
    11-18-2014
    Location
    England
    MS-Off Ver
    365
    Posts
    132

    Re: using INDEX and MACTH in a SUMIF formula

    HI there,

    thanks or the response I have tried this and it just returns an N/A value. Not sure what you mean by logical differences in the cells?

    Thanks

  4. #4
    Forum Contributor
    Join Date
    11-18-2014
    Location
    England
    MS-Off Ver
    365
    Posts
    132

    Re: using INDEX and MACTH in a SUMIF formula

    This is the formula I have been trying to make work

    =SUMIFS(INDEX(table1,,MATCH(A$7,Sheet2!$A$3:$AE$3,0)),Sheet2!$D$4:$D$30,$A8)

  5. #5
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,443

    Re: using INDEX and MACTH in a SUMIF formula

    I would expect this

    ="Week"&" "&D2&" "&"Qualifying" when D2=50 to match cell T3 on sheet2.

    ie, =Sheet1!B7=Sheet2!T3 should return TRUE, but actual returns FALSE.

    Once this issue is resolved, the formula I supplied will work.

  6. #6
    Forum Contributor
    Join Date
    11-18-2014
    Location
    England
    MS-Off Ver
    365
    Posts
    132

    Re: using INDEX and MACTH in a SUMIF formula

    Hi yes that does work you are right. However the reason there was a formula in there, (="Week"&" "&D2&" "&"Qualifying") is because I just wanted to select a week number from a drop down and for the column header to automatically update. is there any way around this?

  7. #7
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,443

    Re: using INDEX and MACTH in a SUMIF formula

    I don't think I'm explaining myself too well - sorry.

    If you take the formula ="Week"&" "&D2&" "&"Qualifying" when D2 contains 50, it should (and does) return "Week 50 Qualifying"

    So, if everything is working as expected, =Match(Sheet1!B7,Sheet2!3:3,0) to return 20, because the 20th cell in row 3:3 contains "Week 50 Qualifying". It doesn't however, because what's actually there could be described like this:

    ="Week 50"&CHAR(10)&"Qualifying"&" "

    The extra space at the end, and the forced carriage return make it not match. Fix the column headers in sheet 2 to make the formulas work.

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: using INDEX and MACTH in a SUMIF formula

    i cant get the 2 to match so i used in b8
    =SUMIF(Sheet2!$D$4:$D$30,$A8,INDEX(Sheet2!$H$4:$AE$30,0,MATCH("*"&$B$6&"*",Sheet2!$H$1:$AE$1,0)))
    in b9
    =SUMIF(Sheet2!$D$4:$D$30,$A8,INDEX(Sheet2!$H$4:$AE$30,0,MATCH("*"&$B$6&"*",Sheet2!$H$1:$AE$1,0)+1))
    in b10
    =SUMIF(Sheet2!$D$4:$D$30,$A8,INDEX(Sheet2!$H$4:$AE$30,0,MATCH("*"&$B$6&"*",Sheet2!$H$1:$AE$1,0)+2))
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  9. #9
    Forum Contributor
    Join Date
    11-18-2014
    Location
    England
    MS-Off Ver
    365
    Posts
    132

    Re: using INDEX and MACTH in a SUMIF formula

    Thank you sweep. I get it now! I have fixed the headers and this works perfectly. I am so grateful for your help!!! If you had a minute I would really like to understand how the OFFSET part of this formula works as I am not entirely sure and I think I would like to use this again and be able to explain it to someone else.

  10. #10
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: using INDEX and MACTH in a SUMIF formula

    hardly any need for offset index is usually sufficient

  11. #11
    Forum Contributor
    Join Date
    11-18-2014
    Location
    England
    MS-Off Ver
    365
    Posts
    132

    Re: using INDEX and MACTH in a SUMIF formula

    Thanks Martindwilson but I have made it work and am nervous to change it now!

  12. #12
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,443

    Re: using INDEX and MACTH in a SUMIF formula

    OFFSET(Sheet2!A4:A30,0,MATCH(B$7,Sheet2!$3:$3,0)-1))

    Sheet2!A4:30 is the origin for the offset - imagine that range selected.

    The second part of the arguements ",0,MATCH(B$7,Sheet2!$3:$3,0)-1" effectively "moves" the selected range down zero rows and across "MATCH(B$7,Sheet2!$3:$3,0)-1" columns

    Martin is correct that OFFSET is inefficient. You could use

    =SUMIF(Sheet2!$D$4:$D$30,Sheet1!$A8,INDEX(Sheet2!$A$4:$AE$4,MATCH(B$7,Sheet2!$3:$3,0)):INDEX(Sheet2!$A$30:$AE$30,MATCH(B$7,Sheet2!$3:$3,0)))

    I used OFFSET in this case as I thought it might be more intuitive to apply.

  13. #13
    Forum Contributor
    Join Date
    11-18-2014
    Location
    England
    MS-Off Ver
    365
    Posts
    132

    Re: using INDEX and MACTH in a SUMIF formula

    Thank you both!. I have made it work using both versions of this formula. Again though as I am a bit of a thickie with INDEX could someone explain to me what it means in the context of this formula if any one has the time?

+ 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. [SOLVED] SumIf & Index formula
    By pbt in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-10-2014, 11:48 AM
  2. Macth, Index or Vlookup?
    By jasonjholt in forum Excel General
    Replies: 7
    Last Post: 03-12-2014, 01:04 PM
  3. [SOLVED] Index Indirect macth
    By namluke in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-12-2013, 11:29 AM
  4. sumif or index formula help
    By ben803 in forum Excel General
    Replies: 8
    Last Post: 10-14-2011, 07:09 PM
  5. Replies: 7
    Last Post: 09-15-2008, 04:03 AM

Tags for this Thread

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