+ Reply to Thread
Results 1 to 16 of 16

EXCEL to return first cell value if a match is found in an array

  1. #1
    Registered User
    Join Date
    11-06-2010
    Location
    Golubari
    MS-Off Ver
    Office 365
    Posts
    11

    EXCEL to return first cell value if a match is found in an array

    Hi

    I have an array of 20 columns and 60 rows (increasing with time), each cell has either text or is blank.
    I want to check if the value of the specific cell (A65 in my example) exist anywhere in this array (row by row)
    IF the value exist then return the value of the 1st column (in my example date) and search value at the row where the match was found.
    So result should be array also with 2 columns and xx rows.

    In each row there can be only one specific value regardles of position (column).

    I tried to use FILTER function but then I need to use sum operator (+) for each row,
    and FILTER function returns complete row.
    example: =FILTER(A1:Z60;(B1:B60=A65)+(C1:C60=A65)+(D1:D60=A65)+(E1:E60=A65)+(F1:F60=A65)+(G1:G60=A65)+(H1:H60=A65)+(I1:I60=A65)+(J1:J60=A65)+(K1:K60=A65)+(L1:L60=A65)+(M1:M60=A65)+(N1:N60=A65)+(O1:O60=A65)+(P1:P60=A65)+(R1:R60=A65);"empty")
    (not all columns included)

    I've tried count, match index, vlookups but nothing seems to really be working for me (or I don't know how to use them).
    I don't want to use VBA.

    Is there a simpler way to filter such a array?

    Thank you for reading this especially if you are able to help me out on this.
    Attached Files Attached Files

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

    Re: EXCEL to return first cell value if a match is found in an array

    How about
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Not sure what you want for the 2nd column
    Last edited by Fluff13; 01-20-2022 at 02:30 PM.

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: EXCEL to return first cell value if a match is found in an array

    Put this formula in cell AA1 on the PS2 sheet:

    =COUNTIF($B$1:$Z1,$A$65)

    Copy down to AA60. Then you can use this formula in cell A66:

    =IF(ROWS($1:1)>MAX($AA:$AA),"",INDEX(A$1:A$60,MATCH(ROWS($1:1),$AA:$AA,0)))

    and format as a date in the style you prefer. Put this very similar formula in B66:

    =IF(ROWS($1:1)>MAX($AA:$AA),"",INDEX(B$1:B$60,MATCH(ROWS($1:1),$AA:$AA,0))&"")

    and copy across to Z66. Then copy all the formulae from row 66 down as far as you think you need them.

    Hope this helps.

    Pete

  4. #4
    Registered User
    Join Date
    11-06-2010
    Location
    Golubari
    MS-Off Ver
    Office 365
    Posts
    11

    Re: EXCEL to return first cell value if a match is found in an array

    Dear Fluff13,
    thank you for your help.
    that's almost what I thought,
    but I don't need to retrive complete row after date,
    only value of the cell A65 in this case.

    In this example that would be
    21.3.2020 T8
    16.5.2020 T8
    29.6.2020 T8
    6.8.2020 T8
    20.8.2020 T8

    I appreciate your help with this.

    Regards

  5. #5
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,781

    Re: EXCEL to return first cell value if a match is found in an array

    A66

    =IFERROR(INDEX($A$1:$A$60,AGGREGATE(15,6,ROW($A$1:$A$60)-ROW($A$1)+1/ISNUMBER(MATCH($B$1:$T$60,$A$65,0)),ROWS($A$1:A1))),"")

    Copy down

  6. #6
    Registered User
    Join Date
    11-06-2010
    Location
    Golubari
    MS-Off Ver
    Office 365
    Posts
    11

    Re: EXCEL to return first cell value if a match is found in an array

    Dear CARACALLA
    Thank you for your time and effort,
    but I need dynamic solution
    because I don't know how many rows will be in a table
    and at the end contain filtered value.

    Again, thanks for all your help

    Regards
    Last edited by AliGW; 01-22-2022 at 04:49 AM. Reason: PLEASE don't quote unnecessarily!

  7. #7
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: EXCEL to return first cell value if a match is found in an array

    Don't I get a mention?

    Pete

  8. #8
    Registered User
    Join Date
    10-02-2020
    Location
    Indonesia
    MS-Off Ver
    365
    Posts
    4

    Re: EXCEL to return first cell value if a match is found in an array

    As far as I see, the date values is unique, there's no entries more than once with same date.
    So all I have to do just pull it's date which is somewhere in its columns contains value equal to input criteria
    I converted your data and the result to Excel Named Ranged Table because it's ability to auto expand and store column formula.
    Attached my file, you may try it if you wish.
    Attached Files Attached Files

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: EXCEL to return first cell value if a match is found in an array

    mp3lab... before going any further, please update your profile. It is obvious that you ar eno longer using Excel 2003.
    Attached Images Attached Images
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  10. #10
    Registered User
    Join Date
    11-06-2010
    Location
    Golubari
    MS-Off Ver
    Office 365
    Posts
    11

    Re: EXCEL to return first cell value if a match is found in an array

    Quote Originally Posted by Glenn Kennedy View Post
    mp3lab... before going any further, please update your profile. It is obvious that you ar eno longer using Excel 2003.
    Done


  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: EXCEL to return first cell value if a match is found in an array

    Thanks!

    maybe this:
    =CHOOSE({1,2},FILTER(A1:A60,MMULT(--(B1:R60=A65),SEQUENCE(17,,,0))>0,"empty"),A65)
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    11-06-2010
    Location
    Golubari
    MS-Off Ver
    Office 365
    Posts
    11

    Re: EXCEL to return first cell value if a match is found in an array

    Dear Pete_UK

    Thank you also for your effort,
    but I'd prefer a dynamic version with FILTER function and spill range

    Anyway, thanks for your help

    Regards
    Last edited by AliGW; 01-22-2022 at 08:09 AM. Reason: PLEASE don't quote unnecessarily!

  13. #13
    Registered User
    Join Date
    11-06-2010
    Location
    Golubari
    MS-Off Ver
    Office 365
    Posts
    11

    Re: EXCEL to return first cell value if a match is found in an array

    Quote Originally Posted by Glenn Kennedy View Post
    Thanks!

    maybe this:
    =CHOOSE({1,2},FILTER(A1:A60,MMULT(--(B1:R60=A65),SEQUENCE(17,,,0))>0,"empty"),A65)
    Dear Glenn Kennedy

    That's exactly what I wanted, but in my Excel config formula is looking like this.

    =CHOOSE({1\2};FILTER(A1:A60;MMULT(--(B1:Z60=A65);SEQUENCE(25;;;0))>0;"empty");A65)

    Thanks for all your help.
    I couldn’t have solve this without you.

    Best Regards

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: EXCEL to return first cell value if a match is found in an array

    Thanks. I sort of expected that, in Serbia, you would require ; inside the formula array {1;2} as well as a separator in the rest of the formula. I had no idea that you would need a \ - I hope I can remember that for the next time.



    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please select "Thread Tools" from the menu link (just above the first post in the thread) and mark this thread as SOLVED.

  15. #15
    Registered User
    Join Date
    11-06-2010
    Location
    Golubari
    MS-Off Ver
    Office 365
    Posts
    11

    Re: EXCEL to return first cell value if a match is found in an array

    It's actually Croatia.

    Reputation Added,
    SOLVED
    Last edited by AliGW; 01-22-2022 at 08:38 AM. Reason: PLEASE don't quote unnecessarily!

  16. #16
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: EXCEL to return first cell value if a match is found in an array

    Ooops!! Sorry.. Bit of a difference, isn't there....

+ 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. [SOLVED] If there is a match using Vlookup Return Found, Otherwise Not Found
    By Howardc1001 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-11-2022, 12:06 AM
  2. [SOLVED] Lookup value and return multiple values to cell when a match is found?
    By The Molecular Level in forum Excel General
    Replies: 3
    Last Post: 08-12-2021, 11:49 AM
  3. [SOLVED] On click, find text, compare and return cell for every found match.
    By y0brah in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-29-2014, 10:41 AM
  4. Find all matches for one cell and when a match found return a ref number VBA
    By ch_abs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-15-2014, 06:15 AM
  5. Replies: 4
    Last Post: 07-16-2012, 04:38 PM
  6. Match/Index array in VBA to return cell address
    By djhsickboy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2011, 02:18 AM
  7. Replies: 5
    Last Post: 10-11-2008, 04:01 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