+ Reply to Thread
Results 1 to 11 of 11

Search returns column header or error if value not found

  1. #1
    Registered User
    Join Date
    01-15-2017
    Location
    LONDON, ENGLAND
    MS-Off Ver
    Excel Mac 2011 14.6.6
    Posts
    55

    Search returns column header or error if value not found

    Hello,



    I need to search a table of data (PAYEES!$A$2:$AQ$200) for a Name (contained in E74) and return the column heading (PAYEES!$A$1:$AQ$1).

    I have this formula:

    Please Login or Register  to view this content.
    which almost works.

    However, this seems to return a value even when there is no match.

    How can I adapt this to return an error when the searched for value is not found?



    Thanks in advance to anyone that helps with this.

  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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: Search returns column header or error if value not found

    Will you please attach a sample Excel workbook?

    1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution is also shown (mock up the results manually).

    3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).

    4. Try to avoid using merged cells as they cause lots of problems.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.
    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
    01-15-2017
    Location
    LONDON, ENGLAND
    MS-Off Ver
    Excel Mac 2011 14.6.6
    Posts
    55

    Re: Search returns column header or error if value not found

    SO... in preparing you an example, I've discovered that the problem was something else, so no worries.

  4. #4
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: Search returns column header or error if value not found

    LOL! Glad to have helped ... sort of.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  5. #5
    Registered User
    Join Date
    01-15-2017
    Location
    LONDON, ENGLAND
    MS-Off Ver
    Excel Mac 2011 14.6.6
    Posts
    55

    Re: Search returns column header or error if value not found

    Actually... turns out it isn't working.

    Can't seem to attach my example though!!

  6. #6
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: Search returns column header or error if value not found

    As I said before, unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

  7. #7
    Registered User
    Join Date
    01-15-2017
    Location
    LONDON, ENGLAND
    MS-Off Ver
    Excel Mac 2011 14.6.6
    Posts
    55

    Re: Search returns column header or error if value not found

    Example hopefully attached...
    Attached Files Attached Files

  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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: Search returns column header or error if value not found

    This should work:

    =IFERROR(INDEX(PAYEES!$A$1:$K$1,IF(SUMPRODUCT((PAYEES!$A$2:$K$4='2016'!C1)*(COLUMN(PAYEES!$A$1:$K$1)))=0,"",SUMPRODUCT((PAYEES!$A$2:$K$4='2016'!C1)*(COLUMN(PAYEES!$A$1:$K$1))))),"")

    confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

  9. #9
    Registered User
    Join Date
    01-15-2017
    Location
    LONDON, ENGLAND
    MS-Off Ver
    Excel Mac 2011 14.6.6
    Posts
    55

    Re: Search returns column header or error if value not found

    Fantastic!

  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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: Search returns column header or error if value not found

    You're welcome!

  11. #11
    Registered User
    Join Date
    01-15-2017
    Location
    LONDON, ENGLAND
    MS-Off Ver
    Excel Mac 2011 14.6.6
    Posts
    55

    Re: Search returns column header or error if value not found

    I actually need more help with this as the problem has evolved slightly. I've started a new thread because this original question has been solved, so it's technically a new problem.

    New thread is here: https://www.excelforum.com/excel-for...le-header.html

+ 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. Replies: 0
    Last Post: 11-15-2016, 02:38 PM
  2. [SOLVED] VLOOKUP returns column where column header matches another cell
    By bridge4444 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-10-2014, 11:23 AM
  3. [SOLVED] Search within a column and repeat the search until all items are found
    By RANDY LIPOSKY in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-09-2014, 10:23 AM
  4. [SOLVED] Search for string across header row, then search for another string down found column
    By TucsonJack in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-14-2012, 02:09 PM
  5. Replace object causes an error if search text not found
    By Scott in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-26-2006, 03:15 PM
  6. search function without error if not found
    By anderssweden in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-14-2006, 10:40 AM
  7. The search key was not found error
    By Nydia in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 04-27-2005, 11:06 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