+ Reply to Thread
Results 1 to 7 of 7

Find First Occurrence Of A Value In A Range Of Cells And Return The Leftmost Column Value

  1. #1
    Registered User
    Join Date
    03-22-2015
    Location
    West Midlands, UK
    MS-Off Ver
    2007
    Posts
    3

    Find First Occurrence Of A Value In A Range Of Cells And Return The Leftmost Column Value

    I have a spreadsheet with customers' names down the leftmost column (Column A.

    Each customer has 5 ticket numbers. There is a column for each of the 5 ticket numbers (Columns B through F). I want to look in the range (B - F) to find a specific ticket number and then return the name of the customer holding that ticket number.

    Any ideas how I do this, please? (It's not VLookUp, I've tried that already and that does the reverse of what I want to do.)

    Screenshot2.jpg

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,662

    Re: Find First Occurrence Of A Value In A Range Of Cells And Return The Leftmost Column Va

    Try :

    =INDEX(A:A,MAX(INDEX((B2:F15=88)*ROW($A$2:$A$15),)))
    Quang PT

  3. #3
    Forum Contributor
    Join Date
    12-22-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    205

    Re: Find First Occurrence Of A Value In A Range Of Cells And Return The Leftmost Column Va

    Interesting problem, i tried all types of formulas to make this work, but couldn't succeed, which prompted me to look further.

    Turns out that this is not a trivial matter to solve with standard excel functions, based on further research i did find a solution using a UDF (user defined function), this solution was found at the following link
    HTML Code: 
    The attached workbook has the UDF included and it works great.
    Attached Files Attached Files

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,662

    Re: Find First Occurrence Of A Value In A Range Of Cells And Return The Leftmost Column Va

    I've tested and it worked:

    =INDEX(A:A,MAX(INDEX((B2:F15=H7)*ROW(A2:A15),)))

  5. #5
    Forum Contributor
    Join Date
    12-22-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    205

    Re: Find First Occurrence Of A Value In A Range Of Cells And Return The Leftmost Column Va

    Quote Originally Posted by bebo021999 View Post
    I've tested and it worked:

    =INDEX(A:A,MAX(INDEX((B2:F15=H7)*ROW(A2:A15),)))
    Yes, this solution works just fine, it actually a nice solution, I will most certainly learn from it, in most cases I would also prefer a non VBA solution.

  6. #6
    Registered User
    Join Date
    03-22-2015
    Location
    West Midlands, UK
    MS-Off Ver
    2007
    Posts
    3

    Re: Find First Occurrence Of A Value In A Range Of Cells And Return The Leftmost Column Va

    Quote Originally Posted by bebo021999 View Post
    Try :

    =INDEX(A:A,MAX(INDEX((B2:F15=88)*ROW($A$2:$A$15),)))
    Thank you, bebo021999. That's a great solution and yes, indeed, it does work. That is, until you have more than one occurrence of the same number. In which case, it does not seem to find the first occurrence.

  7. #7
    Registered User
    Join Date
    03-22-2015
    Location
    West Midlands, UK
    MS-Off Ver
    2007
    Posts
    3

    Re: Find First Occurrence Of A Value In A Range Of Cells And Return The Leftmost Column Va

    Quote Originally Posted by jprlimey View Post
    Interesting problem, i tried all types of formulas to make this work, but couldn't succeed, which prompted me to look further.

    Turns out that this is not a trivial matter to solve with standard excel functions, based on further research i did find a solution using a UDF (user defined function), this solution was found at the following link
    HTML Code: 
    The attached workbook has the UDF included and it works great.
    Thanks, jprlimey. This does the trick perfectly! #ThumbsUp

+ 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. Find each occurrence in a column and do for each occurrence
    By jfoerch in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-21-2014, 12:29 PM
  2. Replies: 3
    Last Post: 09-15-2014, 07:56 PM
  3. [SOLVED] Find last occurrence of text in a column and return value in next column
    By LindaLu in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-06-2014, 09:45 AM
  4. [SOLVED] Can I look for a number in a range and return the leftmost value?
    By hornet7 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-13-2013, 11:49 AM
  5. Replies: 2
    Last Post: 09-09-2013, 06:44 PM

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