+ Reply to Thread
Results 1 to 10 of 10

MATCH the next item IF

  1. #1
    Registered User
    Join Date
    10-24-2012
    Location
    Guelph, ON
    MS-Off Ver
    Excel 2010
    Posts
    41

    Question MATCH the next item IF

    Hello: I'm trying to create a condensed version of a table that pulls out variances and ignores all zeros. I've used an array with SMALL to successfully pull out a list of variances. However now I want to attach a customer name to each variance. The problem I've encountered is that if 2 customers have the same variance I don't know how to implement the IF statement so that it will go to the next match and return the next customer. I've tried various approaches and formulas without any luck.

    I've attached a spreadsheet example where I have a list of customers in Column A, their Variances in Column B. In Columns D & E I want to set up a table where you only show the variances. Column D is the customer and E is their variance. Problem is that Customer A and E have the same variance of -1055 and so the table returns A for both instances. I would like the 2nd instance to show me customer E. Hopefully that makes sense.

    Thanks!
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by SCarroll; 06-15-2022 at 12:15 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    11-22-2014
    Location
    Arizona, USA
    MS-Off Ver
    Office 365
    Posts
    973

    Re: MATCH the next item IF

    Move away from the MATCH in this instance, instead FILTER your list

    Your named range is on B2:B27 thus it says var_lookup in the formula... otherwise just remember to be consistent with your selected ranges(array) and filter ranges

    Please Login or Register  to view this content.
    -If you think you are done, Start over - ELeGault

  3. #3
    Valued Forum Contributor
    Join Date
    11-22-2014
    Location
    Arizona, USA
    MS-Off Ver
    Office 365
    Posts
    973

    Re: MATCH the next item IF

    2010 - you do not have Filter... okay so the fastest route would be add a helper column. Light weight as its a per line review...

    Insert a column in front of A so your AB becomes BC. Then in A2 put this
    =IF(C2=0,A1,A1+1)

    Send the formula down to the length of your data. What you will see is something like this

    1
    1
    1
    2
    3
    3
    3
    etc...

    Each time it hits a record that is not 0 it will add a number to the previous otherwise it will repeat the previous.

    You can now match on that value based on position in your list

    Index your range then match on the count of records from header to current position.
    Then Match on COL reference also by getting a count of columns again from headers.

    This formula will go into what is now your column E row 2 and throughout the light green table you have!
    =IFERROR(INDEX($B$2:$C$27,MATCH(COUNTA($E$1:$E1),$A$2:$A$27,0),COUNTA($E$1:E$1)),"")

  4. #4
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: MATCH the next item IF

    FILTER is probably the best option if you have a newer version of Excel. If not, try this:

    in D2:

    =IFERROR(INDEX(Customer_list,AGGREGATE(15,7,IF(var_lookup<>0,ROW(var_lookup),NA()),ROWS(E2:E$2))-1),"")

    In E2:

    =IFERROR(INDEX(var_lookup,AGGREGATE(15,7,IF(var_lookup<>0,ROW(var_lookup),NA()),ROWS(F2:F$2))-1),"")

    Both copied down.

  5. #5
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: MATCH the next item IF

    Another option
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-24-2012
    Location
    Guelph, ON
    MS-Off Ver
    Excel 2010
    Posts
    41

    Smile Re: MATCH the next item IF

    Got it! Thanks! Small correction to the formula - =FILTER(A2:A27,var_lookup<>0,"") and it worked!
    Last edited by SCarroll; 06-15-2022 at 12:11 PM.

  7. #7
    Registered User
    Join Date
    10-24-2012
    Location
    Guelph, ON
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: MATCH the next item IF

    Thanks! I have FILTER so that worked. But this is good to know as well because I have someone I help who is still using 2007.

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: MATCH the next item IF

    SCarroll glad you found solution.

    If that formula works then your profile is not current. As ELeGault mentions in post #3 FILTER is not an Office 2010 function.

    Please update your profile. It helps us help you.

    Edit: It appears our posts crossed in the ether.
    Last edited by FlameRetired; 06-15-2022 at 12:26 PM.
    Dave

  9. #9
    Registered User
    Join Date
    10-24-2012
    Location
    Guelph, ON
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: MATCH the next item IF

    Quote Originally Posted by ELeGault View Post
    2010 - you do not have Filter... okay so the fastest route would be add a helper column. Light weight as its a per line review...

    Insert a column in front of A so your AB becomes BC. Then in A2 put this
    =IF(C2=0,A1,A1+1)

    Send the formula down to the length of your data. What you will see is something like this

    1
    1
    1
    2
    3
    3
    3
    etc...

    Each time it hits a record that is not 0 it will add a number to the previous otherwise it will repeat the previous.

    You can now match on that value based on position in your list

    Index your range then match on the count of records from header to current position.
    Then Match on COL reference also by getting a count of columns again from headers.

    This formula will go into what is now your column E row 2 and throughout the light green table you have!
    =IFERROR(INDEX($B$2:$C$27,MATCH(COUNTA($E$1:$E1),$A$2:$A$27,0),COUNTA($E$1:E$1)),"")
    This is also a clever solution! Sometimes I overlook the simple things. But the Filter did work! Thank you!

  10. #10
    Valued Forum Contributor
    Join Date
    11-22-2014
    Location
    Arizona, USA
    MS-Off Ver
    Office 365
    Posts
    973

    Re: MATCH the next item IF

    Glad it worked - Sometimes its the simple solutions that are over engineered. Who knew that the step we wanted to take was simply the next one!

    Be sure to update your profile. If Filter is working then you are on a later version which is why I offered the second solution to begin with. It helps us (Anyone helping) tailor a solution to the environment you work in. This means it could also prevent very robust and exciting methods to be kept from you because you appear to be on an old instance!

    Glad it worked though!

    Cheers
    - Eddie

+ 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. Match Item with Invoice and Replace any missing Item AUTO
    By majidsiddique in forum Excel General
    Replies: 17
    Last Post: 01-15-2019, 03:43 AM
  2. How to Match Item Price with Item Automatically
    By sunilvdkn in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-24-2018, 05:03 AM
  3. Replies: 3
    Last Post: 06-03-2018, 01:23 AM
  4. [SOLVED] Find item(s) in a cell and match to item(s) in a list
    By seleseped in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-11-2017, 12:06 PM
  5. [SOLVED] Vba to match item description and copy/paste item code to other sheet
    By sintek in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2017, 11:29 AM
  6. [SOLVED] need to flag item when doesnt match the item above it
    By mcarp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-20-2014, 08:40 AM
  7. Replies: 9
    Last Post: 05-21-2011, 12:14 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