+ Reply to Thread
Results 1 to 6 of 6

Cannot find a header when value repeats in a column

  1. #1
    Registered User
    Join Date
    03-19-2020
    Location
    DK
    MS-Off Ver
    MS Office 2016
    Posts
    4

    Cannot find a header when value repeats in a column

    Hello everyone,

    I need to find headers from different sheets in column M:M. I came up with the formula but it fails when it discovers several repeating values in the same column.

    What is missing that formula would return to a header even if the values are repeating in the column?

    Any suggestion how to solve this is appreciated :)
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    06-22-2018
    Location
    Blackpool, England
    MS-Off Ver
    2019
    Posts
    408

    Re: Cannot find a header when value repeats in a column

    How about trying this in M1 and copying down?
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Does that do it for you?

    Tim
    Never stop learning!
    <--- please consider *-ing !

  3. #3
    Valued Forum Contributor loginjmor's Avatar
    Join Date
    01-31-2013
    Location
    Cedar Rapids, Iowa
    MS-Off Ver
    Excel 2013
    Posts
    1,073

    Re: Cannot find a header when value repeats in a column

    Hi -

    The problem with your formula is SUMPRODUCT will continue to add and multiply every match it finds. So then your column number grows with every match, way beyond the limit of your INDEX search array.

    I suggest two things:

    1. Instead of using multiple IF statements to select which Tab to go to, use the INDIRECT function to point the formula to the correct Tab automatically.

    2. Use and IF statement as an Array formula to compare every number in your search array to the value you are looking for. Since the duplicates appear to always show up in the same column, simply take the MAX of the array that is created to find the column number. If there happens to be two columns with the same number, you will have to decide which one you want to use. In this case you will get the highest column number.

    The formula I would recommend looks like this:

    =IFERROR(INDEX(INDIRECT(H1&"!$B$1:$L$1"),,MAX(IF(L1=INDIRECT(H1&"!$B$2:$L$52"),COLUMN(INDIRECT(H1&"!$B$2:$L$52")),0))-1),"No Match")

    For the Error message, I personally prefer "No Match" rather than " ", but that is up to you. It is easy enough to change.

    I have attached your workbook with the above changes included.

    Hope this helps.
    Attached Files Attached Files
    ____________________________________________
    If this has solved your problem, please edit the thread title to add the word [SOLVED] at the beginning. You can do this by
    -Go to the top of the first post
    -Select Thread Tools
    -Select Mark thread as Solved

    If I have been particularly helpful, please "bump" my reputation by pressing the small star in the lower left corner of my post.

  4. #4
    Valued Forum Contributor
    Join Date
    06-22-2018
    Location
    Blackpool, England
    MS-Off Ver
    2019
    Posts
    408

    Re: Cannot find a header when value repeats in a column

    Aaaaaand having re-read the question, I see I completely missed the point!

    joginjmor's response, however, is spot on!

    Tim

  5. #5
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,820

    Re: Cannot find a header when value repeats in a column

    Please try the following in cell M1 and copied down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    This is a regular formula so just press the Enter key to activate.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  6. #6
    Valued Forum Contributor
    Join Date
    06-22-2018
    Location
    Blackpool, England
    MS-Off Ver
    2019
    Posts
    408

    Re: Cannot find a header when value repeats in a column

    NB: You can achieve the same with an adaptation of your own formula if you don't want to use an an array formula (with CTRL+SHIFT+ENTER) like this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Tim

+ 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] Find specific value in table and return header row and header column value
    By nelwan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-30-2013, 01:35 AM
  2. Replies: 1
    Last Post: 11-15-2013, 10:59 AM
  3. Replies: 2
    Last Post: 04-26-2013, 01:16 PM
  4. Undo VBA code repeats only on table header for some reason. Can't figure out why.
    By drew.j.harrison in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-27-2013, 01:44 AM
  5. Replies: 6
    Last Post: 12-09-2012, 09:00 PM
  6. Search for column header and find all values and their row numbers in that column
    By woody83 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-14-2012, 03:11 PM
  7. Replies: 3
    Last Post: 07-04-2008, 07:42 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