+ Reply to Thread
Results 1 to 5 of 5

If range contains one of the values in the array, return the index of the array

  1. #1
    Registered User
    Join Date
    05-12-2017
    Location
    Hong Kong
    MS-Off Ver
    2016
    Posts
    12

    If range contains one of the values in the array, return the index of the array

    Hello everyone,

    I am using Microsoft Excel 2016.
    If a range contains one of the values in the array, I wonder how can I return the index of the array?
    Please see the attachment for the samples.

    Thanks a lot,
    Lawrence
    Last edited by LawCarrot; 03-01-2018 at 04:05 AM.

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,914

    Re: If range contains one of the values in the array, return the index of the array

    Try:

    =LOOKUP(1,-SEARCH($E$2:$E$5,A2),$F$2:$F$5)

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,225

    Re: If range contains one of the values in the array, return the index of the array

    In B2

    =IF(SUMPRODUCT((--ISNUMBER(SEARCH($E$1:$E$5,A2))*ROW($E$1:$E$5))),INDEX($F$1:$F$5,SUMPRODUCT((--ISNUMBER(SEARCH($E$1:$E$5,A2))*ROW($E$1:$E$5)))),"N/A")

    copy down

  4. #4
    Registered User
    Join Date
    05-12-2017
    Location
    Hong Kong
    MS-Off Ver
    2016
    Posts
    12

    Re: If range contains one of the values in the array, return the index of the array

    Thank you very much for helping out too, JohnTopley!
    Your solution works perfectly on my sample workbook, but once I adjusted and applied it to another workbook, it keeps on showing the #REF! error
    I guess the problem may be that my array and index list is not on the same worksheet of the range's worksheet, that's why the error is caused
    Last edited by LawCarrot; 03-01-2018 at 04:11 AM.

  5. #5
    Registered User
    Join Date
    05-12-2017
    Location
    Hong Kong
    MS-Off Ver
    2016
    Posts
    12

    Re: If range contains one of the values in the array, return the index of the array

    Thank you very much, Phuocam! It works exactly as expected! Do you mind explaining a bit on how it works?

+ 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. Index Array return values between dates
    By Prospidnick in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-14-2017, 11:17 AM
  2. Index array to return me a list of values
    By xatomicx in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-04-2017, 05:31 PM
  3. Replies: 2
    Last Post: 03-15-2017, 08:22 AM
  4. Replies: 5
    Last Post: 12-02-2015, 05:23 AM
  5. Replies: 7
    Last Post: 10-10-2014, 05:40 PM
  6. Use Index/Match Function to Return Values from an Array
    By 00pumpkin in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-11-2013, 02:22 PM
  7. Find a value in an array and return multiple values in an adjacent array
    By tonbra in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2012, 08:35 PM

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