+ Reply to Thread
Results 1 to 15 of 15

VLOOKUP or Mixture of Index/Match to return a value

  1. #1
    Registered User
    Join Date
    08-07-2012
    Location
    charlotte, nc
    MS-Off Ver
    Excel 2013
    Posts
    11

    VLOOKUP or Mixture of Index/Match to return a value

    I want to provide an example of the data I have and see if you guys can help me figure this out in a formula (macros can't be used):

    So if I run the VLOOKUP found in Column D right now, it returns "S" because that's the first row with the TIN 12345. Then I drag the formula down and get all of them as S.

    Now, what if I wanted to put SUE in all of the rows for this TIN? How can I make it return SUE instead of S? Essentially saying "For this TIN if you find a name that's more than a length of 1, use that name instead".

    This spreadsheet has thousands of rows of data. I am just trying to provide the best Middle Name possible for each TIN.

    I thought about a VLOOKUP with INDEX/MATCH, but I am just a bit confused by that approach.
    Attached Files Attached Files
    Last edited by igotgame; 07-28-2021 at 09:12 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,558

    Re: VLOOKUP or Mixture of Index/Match to return a value

    There are instructions at the top of the page explaining how to attach your sample workbook.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    08-07-2012
    Location
    charlotte, nc
    MS-Off Ver
    Excel 2013
    Posts
    11

    Re: VLOOKUP or Mixture of Index/Match to return a value

    Sorry about that, post has been updated

  4. #4
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.85 for Mac MS 365
    Posts
    8,513

    Re: VLOOKUP or Mixture of Index/Match to return a value

    I suspect there is more to it but based on what you've posted and your workbook, this should work...
    =IFERROR(IF(VLOOKUP(A2,A:B,2,FALSE)="S","SUE"),"")
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  5. #5
    Registered User
    Join Date
    08-07-2012
    Location
    charlotte, nc
    MS-Off Ver
    Excel 2013
    Posts
    11

    Re: VLOOKUP or Mixture of Index/Match to return a value

    Well there are thousands of rows in this workbook with multiple people (TINs) and names so you have to key off of TIN first to make sure you are on the right record, but then finding the longest middle name basically for that TIN is where I am struggling.
    Last edited by AliGW; 07-28-2021 at 08:59 AM. Reason: PLEASE don't quote unnecessarily!

  6. #6
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.85 for Mac MS 365
    Posts
    8,513

    Re: VLOOKUP or Mixture of Index/Match to return a value

    Maybe you need to post a more representative sample (more than one example) and hand enter your desired results to get a better formula.
    If you have a lot of repeats of the same TIN you might want to set up a table to reference.

  7. #7
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,547

    Re: VLOOKUP or Mixture of Index/Match to return a value

    Cell D2 formula , Drag down

    HTML Code: 

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,558

    Re: VLOOKUP or Mixture of Index/Match to return a value

    @igotgame

    Are you still using Excel 2003? If not, please update your forum profile.

  9. #9
    Registered User
    Join Date
    08-07-2012
    Location
    charlotte, nc
    MS-Off Ver
    Excel 2013
    Posts
    11

    Re: VLOOKUP or Mixture of Index/Match to return a value

    Quote Originally Posted by Sam Capricci View Post
    Maybe you need to post a more representative sample (more than one example) and hand enter your desired results to get a better formula.
    If you have a lot of repeats of the same TIN you might want to set up a table to reference.
    I have updated the original post with a better sample file. Let me know if that helps.

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,558

    Re: VLOOKUP or Mixture of Index/Match to return a value

    Try this:

    =INDEX($B$2:$B$21,MATCH(1,($A$2:$A$21=A2)*(MAX(IF($A$2:$A$21=A2,LEN($B$2:$B$21)))=LEN($B$2:$B$21)),0))

    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

  11. #11
    Registered User
    Join Date
    08-07-2012
    Location
    charlotte, nc
    MS-Off Ver
    Excel 2013
    Posts
    11

    Re: VLOOKUP or Mixture of Index/Match to return a value

    I may have it..I believe this is the formula:
    =INDEX(B:B,MATCH(MAX(INDEX(LEN(B:B)*(A:A=A2),)),INDEX(LEN(B:B)*(A:A=A2),),0))

    Now....I need to incorporate CLOSED/OPEN if possible somehow so it only pulls the longest name if the account is OPEN basically.

    EDIT: Thanks Ali...I believe I posted my solution at the same time you were posting yours.
    Last edited by igotgame; 07-28-2021 at 09:37 AM.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,558

    Re: VLOOKUP or Mixture of Index/Match to return a value

    This?

    =INDEX($B$2:$B$21,MATCH(1,($A$2:$A$21=A2)*($C$2:$C$21="OPEN")*(MAX(IF($A$2:$A$21=A2,IF($C$2:$C$21="OPEN",LEN($B$2:$B$21))))=LEN($B$2:$B$21)),0))

  13. #13
    Registered User
    Join Date
    08-07-2012
    Location
    charlotte, nc
    MS-Off Ver
    Excel 2013
    Posts
    11

    Re: VLOOKUP or Mixture of Index/Match to return a value

    Thank you very much! Works!
    Last edited by AliGW; 07-28-2021 at 09:50 AM. Reason: PLEASE don't quote unnecessarily!

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,558

    Re: VLOOKUP or Mixture of Index/Match to return a value

    Thank you very much! Works!
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  15. #15
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,547

    Re: VLOOKUP or Mixture of Index/Match to return a value

    Cell E2 array formula , drag down

    HTML Code: 
    Last edited by wk9128; 07-28-2021 at 07:32 PM.

+ 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. using index match or vlookup to return an image
    By jml2 in forum Excel General
    Replies: 4
    Last Post: 11-20-2019, 11:59 PM
  2. [SOLVED] Vlookup/index/match to return maximum number
    By dave_100 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-20-2016, 06:40 PM
  3. [SOLVED] Need Vlookup or Index Match to return multiple values
    By harrydnyc in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-28-2016, 05:52 PM
  4. [SOLVED] Vlookup/index/match to return all values that match
    By Asil01 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 10-09-2014, 12:49 PM
  5. VLOOKUP/INDEX/MATCH to return all values that match
    By lijia00 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2014, 11:56 AM
  6. Replies: 2
    Last Post: 01-12-2012, 07:02 AM
  7. Index Match or Vlookup to return values?
    By Chesney95 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-30-2007, 11:05 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