+ Reply to Thread
Results 1 to 7 of 7

Formula to find first value that is NON-ZERO with a VLOOKUP

  1. #1
    Registered User
    Join Date
    02-15-2011
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    21

    Formula to find first value that is NON-ZERO with a VLOOKUP

    Hello-

    I am looking for help with a formula in the attached sample data spreadsheet. To describe it, basically I have a data set with a bunch of order numbers in column A and their values going out by date in columns B through whatever depending on the date. In the other sheet I have a list of Order numbers and am trying to write a formula to return the first value for that order that is not zero.

    Here is my current formula, which does not work.

    Please Login or Register  to view this content.
    Unfortunatley, the way the data is maintained, I cannot get the list of orders in the WORKSHEET tab to be in the same order as the DATA tab, so a formula around this problem would be a great help.

    Many thanks in advance for your help!!!
    Attached Files Attached Files
    Last edited by NBVC; 06-09-2011 at 09:56 AM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Formula to find first value that is NON-ZERO with a VLOOKUP

    Try:

    PHP Code: 
    =INDEX(INDEX(Data!$B$2:$L$18,MATCH(C5,Data!$A$2:$A$18,0),0),MATCH(TRUE,INDEX(INDEX(Data!$B$2:$L$18,MATCH(C5,Data!$A$2:$A$18,0),0)>0,0),0)) 
    copied down
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    02-15-2011
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Formula to find first value that is NON-ZERO with a VLOOKUP

    Thank you, this works great!

  4. #4
    Registered User
    Join Date
    09-17-2014
    Location
    Edinburgh
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Formula to find first value that is NON-ZERO with a VLOOKUP

    I tried to use this formula with a single list of data values but I get an error. Any idea what I need to change to get it to work with a one dimensional list. The formula which solved the original problem is:

    =INDEX(INDEX(Data!$B$2:$L$18,MATCH(C5,Data!$A$2:$A$18,0),0),MATCH(TRUE,INDEX(INDEX(Data!$B$2:$L$18,MATCH(C5,Data!$A$2:$A$18,0),0)>0,0),0))

    I changed the range $B$2:$L$18 to $B$2:$B$18 but it gives the value error.

  5. #5
    Registered User
    Join Date
    03-01-2020
    Location
    London
    MS-Off Ver
    Office 365 (PC) and Mac 16.16.19
    Posts
    10

    Re: Formula to find first value that is NON-ZERO with a VLOOKUP

    Hi,

    Can anyone help me modify this example to search vertically instead of horizontally.

    I've tried adapting the formula in the working answer but it returns the correct answer for all bar the one i need it to!

    I've attached my adapted workbook.

    Thanks in advance..
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Formula to find first value that is NON-ZERO with a VLOOKUP

    Data!c2 =IF(B2=0,"",A2&"yes") and drag down.

    Worksheet!E5 =INDEX(Data!$A$1:$C$18,MATCH(Worksheet!C5&"yes",Data!$C$1:$C$18,0),2) and drag down.

    See the attached file.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  7. #7
    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: Formula to find first value that is NON-ZERO with a VLOOKUP

    Quote Originally Posted by moconn View Post
    Hi,

    Can anyone help me modify this example to search vertically instead of horizontally.

    I've tried adapting the formula in the working answer but it returns the correct answer for all bar the one i need it to!

    I've attached my adapted workbook.

    Thanks in advance..
    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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