+ Reply to Thread
Results 1 to 10 of 10

How to return multiple results in a search

  1. #1
    Registered User
    Join Date
    07-30-2012
    Location
    Waianae, HI
    MS-Off Ver
    MSO 365 version 1909
    Posts
    38

    How to return multiple results in a search

    I've got a small problem that I can't seem to figure out and need some help. I've attached the file for example. On the "PT Scores" tab, there is a status "MEB" listed next to a couple of names. I need to be able to return then names to the "Status" tab, under MEB:, preferably in a comma separated format. I'm using a government system and cannot use VB.
    Attached Files Attached Files

  2. #2
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: How to return multiple results in a search

    Hi jrlafrance- I have a solution that (currently) involves adding a helper column on the PT Scores sheet. This holds names in this format: "Smith, John".
    Paste this ARRAY FORMULA in Status!A2, then press CTRL+SHIFT+ENTER to confirm. Now use the drag handle to fill down.

    =IFERROR(INDEX(('PT Scores'!$D$2:$D$10000),MATCH(0,(COUNTIF(Status!$A$1:$A1,'PT Scores'!$D$2:$D$10000)+('PT Scores'!$C$2:$C$10000<>Status!$A$1)),0)),"")

    NOTE: If after pasting, the formula appears as TEXT, a leading space got copied. Return to the formula bar and delete the space, then
    press CTRL+SHIFT+ENTER again.


    Please see the attached workbook. I will attempt to eliminate the helper column. Check back in 45 min. -Lee

    Helper Column removed. See post # 5 for updated versions of workbook and formula.
    Last edited by leelnich; 05-18-2017 at 11:38 PM.

  3. #3
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: How to return multiple results in a search

    I have some questions:
    Are the names on the PT Scores list unique, or can the same person appear more than once?
    If a person can appear twice, can that person also have 2 MEB's?
    Roughly how many names on the list?

    My original formula assumed names on the PT Scores list were NOT unique. It can be simplified if that is not the case.

  4. #4
    Registered User
    Join Date
    07-30-2012
    Location
    Waianae, HI
    MS-Off Ver
    MSO 365 version 1909
    Posts
    38

    Re: How to return multiple results in a search

    All the names are unique, and there are roughly 150 of them. Only 1 person can have 1 MEB.
    I tried to download the file you attached, but was unable. I think the problem might stem from being on a government system.

  5. #5
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: How to return multiple results in a search

    OK, I was able to eliminate the extra column. Names in the MEB column are in this format: "Smith, John", all one word.
    IMPORTANT: In cell A1 of the Status Sheet, the header "MEB:" must be changed to "MEB" to conform with the spelling on the other Sheet.

    Paste this ARRAY FORMULA in Status!A2, then press CTRL+SHIFT+ENTER to confirm. Now use the drag handle to fill down.

    =IFERROR(INDEX('PT Scores'!$A$1:$A$1000 & ", "&'PT Scores'!$B$1:$B$1000,SMALL(('PT Scores'!$C$1:$C$1000<>Status!$A$1)*50000+ROW($A$1:$A$1000),ROWS($A$1:$A1))),"")

    NOTE: If after pasting, the formula appears as TEXT, a leading space has been copied and pasted. This is a known issue with the website.
    Return to the formula bar and delete the space to the LEFT of the "=" sign, then press CTRL+SHIFT+ENTER again.

    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee
    Attached Files Attached Files
    Last edited by leelnich; 05-18-2017 at 11:33 PM.

  6. #6
    Registered User
    Join Date
    07-30-2012
    Location
    Waianae, HI
    MS-Off Ver
    MSO 365 version 1909
    Posts
    38

    Re: How to return multiple results in a search

    So as soon as I click anywhere in the worksheet, in cell A2 it changes from "Smith, John" to "LastName, First Name". And when I drag the formula down, the following cells display nothing. This is pretty advanced for me, I'm not understanding why you added "*5000" into the formula. The first formula worked well, I might just stick with that one.

  7. #7
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: How to return multiple results in a search

    No problem, you just didn't get the ARRAY FORMULA confirmed correctly. Select A2 and then press the F2 key. This puts you in the formula bar. Now press CTRL+SHIFT+ENTER all at the same time. Curly brackets {} should appear around the formula, indicating the ARRAY status is confirmed. Now look for the little green box at the bottom right corner of the cell. That's the "drag handle". Click and hold while you DRAG down the column to extend the selection. This fills (copies) the formula to the cells you select. Go down as far as you need to. NOW you should see correct results. Remember, CTRL+SHIFT+ENTER must be pressed WHENEVER you finish editing an ARRAY FORMULA.
    Last edited by leelnich; 05-19-2017 at 01:19 AM.

  8. #8
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: How to return multiple results in a search

    =IFERROR(INDEX(AllLastNames" , "AllFirstNames,SMALL((AllReasons<>MEB)*50000+AllRowNumbers, RowToShow)),"")

    Let me try to explain. As I've been saying, this is an Array Formula. That means it works with a bunch of inputs, but produces just one result. Lots of built-in Excel functions do this, like SUM, COUNT, MAX, and one I've used here: SMALL(V1,V2,V3,...,k_Number). This function looks at an array of values, and returns the k-th smallest. So, in this case, I build an array by looking at each row to see if MEB is present. If TRUE, 0. If FALSE,1. Then I multiply each 1 or 0 by 50000 and add the number of the row where it occurs. This gives me a list containing the row number of every row where MEB was found, and the row number + 50000 of every row where it was NOT found. Now SMALL comes into play. The same list is generated in every cell containing the formula, but each of those is on a DIFFERENT ROW. So each cell uses its own Row Number to determine which value in the list to display. First (top) cell displays the 1st smallest value, Second cell displays the 2nd smallest, and so on, until there are no more values to show.
    Last edited by leelnich; 05-19-2017 at 01:16 AM.

  9. #9
    Registered User
    Join Date
    07-30-2012
    Location
    Waianae, HI
    MS-Off Ver
    MSO 365 version 1909
    Posts
    38

    Re: How to return multiple results in a search

    In the formula, what worksheet are these referring to "ROW($A$1:$A$1000),ROWS($A$1:$A1)"? I've tried inserting this into my workbook, but I haven't gotten it to work yet.

  10. #10
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: How to return multiple results in a search

    Enter array formula in A2 on Status Sheet and copy down
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    **Must be entered with Ctrl+Shift+Enter key combination.
    v A
    1 MEB
    2 Smith, John
    3 Peters, Derrick
    4
    5
    6
    7
    8
    Attached Files Attached Files
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

+ 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] Multiple search criteria to return multiple results
    By johnmacs5 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-01-2016, 05:17 PM
  2. [SOLVED] Code to search Excel and return results even if part of search text is present
    By Taoyuan00 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2016, 09:20 AM
  3. Replies: 6
    Last Post: 08-22-2014, 08:47 AM
  4. Search a cell for multiple words and return multiple results in one cell
    By samanthat86 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-23-2013, 12:01 PM
  5. Search Workbook for cells that meet multiple criteria and return results from rows
    By CFritz7 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-27-2013, 04:41 PM
  6. Search multiple sheets and return list of multiple results
    By Abuck in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 03-07-2012, 11:59 AM
  7. User Form to Search multiple Criteria to return multiple Results
    By Calieth in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-16-2011, 11:57 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