+ Reply to Thread
Results 1 to 11 of 11

Vlookup and sumif formula is failing

  1. #1
    Forum Contributor
    Join Date
    06-10-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    272

    Vlookup and sumif formula is failing

    The following formula is failing to return any stock value if the first stock item in column B is zero. If anyone can help to correct it that would be great.


    =IF(IF(ISERROR(VLOOKUP(H8,Stock!$A$2:$B$23,2,FALSE)),0,IF(VLOOKUP(H8,Stock!$A$2:$B$23,2,FALSE)-SUMIF($H$7:$H7,$H8,$E$7:$E7)>E8,E8,VLOOKUP(H8,Stock!$A$2:$B$23,2,FALSE)-SUMIF($H$7:$H7,$H8,$E$7:$E7)))<0,0,IF(ISERROR(VLOOKUP(H8,Stock!$A$2:$B$23,2,FALSE)),0,IF(VLOOKUP(H8,Stock!$A$2:$B$23,2,FALSE)-SUMIF($H$7:$H7,$H8,$E$7:$E7)>E8,E8,VLOOKUP(H8,Stock!$A$2:$B$23,2,FALSE)-SUMIF($H$7:$H7,$H8,$E$7:$E7))))

    Thank you

  2. #2
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Vlookup and sumif formula is failing

    pls attach sample file
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  3. #3
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Vlookup and sumif formula is failing

    Quote Originally Posted by sipa View Post
    The following formula is failing to return any stock value if the first stock item in column B is zero. If anyone can help to correct it that would be great.
    Please Login or Register  to view this content.
    What do you mean by "failing to return any value"?

    As written, the formula always returns zero, E8 or the positive difference VLOOKUP(H8,Stock!$A$2:$B$23,2,FALSE)-SUMIF($H$7:$H7,$H8,$E$7:$E7). Those are all values per se. Do you mean the formula always returns zero?

    We will probably need to see an example Excel file that demonstrates the problem in order to explain why the formula always returns zero. There are oh-so-many possibilities. But someone might get lucky with a wild guess.

    You can attach the file to a response using this forum's API. Alternatively, upload the file to a file-sharing website and post the public/shared URL in a response.

    FYI, the formula can be simplified as follows:

    Please Login or Register  to view this content.
    I do not expect that improvement to change the behavior.

  4. #4
    Forum Contributor
    Join Date
    06-10-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    272

    Re: Vlookup and sumif formula is failing

    Thank you for your interest in my current problem.

    I've attached a sample workbook to try to show what I'd like to achieve.
    I think my previous approach is completely wrong, hopefully you can help.
    Attached Files Attached Files

  5. #5
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Vlookup and sumif formula is failing

    See the attached file
    one supporting column
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    06-10-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    272

    Re: Vlookup and sumif formula is failing

    Hi, thanks for the revision, it does work.

    Is there any way to avoid using a helper column ? if so, that would be perfect.

  7. #7
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Vlookup and sumif formula is failing

    D3=INDEX(ROW(INDIRECT(MIN(Stock!$D$2:$D$23)&":"&MAX(Stock!$D$2:$D$23))),MATCH(TRUE,INDEX(INDEX(SUMIFS(Stock!$B$2:$B$23,Stock!$A$2:$A$23,$A3,Stock!$D$2:$D$23,"<="&ROW(INDIRECT(MIN(Stock!$D$2:$D$23)&":"&MAX(Stock!$D$2:$D$23)))),0)>=SUMIF(A$3:A3,A3,B$3:B3),0),0))

    COPY TOWARDS DOWN

  8. #8
    Forum Contributor
    Join Date
    06-10-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    272

    Re: Vlookup and sumif formula is failing

    nflsales,

    Thank you very much, your solution works perfectly!
    I will mark the thread as solved, and add to your reputation.

    Thanks again

  9. #9
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Vlookup and sumif formula is failing

    I used this formula to get the same results:

    =MAX(Stock!D:D)-SUMPRODUCT(0+(SUMIFS(Stock!B:B,Stock!A:A,A3,Stock!D:D,"<="&ROW(INDIRECT("1:"&MAX(Stock!D:D)-MIN(Stock!D:D)+1))+MIN(Stock!D:D)-1)>=SUMIF(A$3:A3,A3,B$3:B3)))+1
    Audere est facere

  10. #10
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Vlookup and sumif formula is failing

    Thanks @sipa and @ Daddylonglegs for adding reputation

  11. #11
    Forum Contributor
    Join Date
    06-10-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    272

    Re: Vlookup and sumif formula is failing

    Thank you daddylonglegs, for your contribution too. Iit always amazes me how there are so many different solutions there seem to be to a single problem.

    You guy's are awesome!

    Of the two solutions offered, which would be faster ?

+ 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. SumIf Index Match - 4 conditions (failing miserably! :(
    By Keelin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-10-2014, 07:26 AM
  2. [SOLVED] VLOOKUP SUMIF Formula
    By jj554 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-27-2013, 11:06 PM
  3. Vlookup failing when value is a formula
    By Opy in forum Excel General
    Replies: 3
    Last Post: 08-31-2011, 09:53 PM
  4. VLOOKUP is failing me
    By scottnoddin77 in forum Excel General
    Replies: 4
    Last Post: 12-13-2006, 08:16 PM
  5. Do I need a sumif or sum of a vlookup formula?
    By Pauliec in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-01-2005, 07:23 AM

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