+ Reply to Thread
Results 1 to 9 of 9

Retrieving Table Headers

  1. #1
    Registered User
    Join Date
    05-25-2017
    Location
    Buchs, Switzlerand
    MS-Off Ver
    2019
    Posts
    75

    Retrieving Table Headers

    Hello everyone,

    I am familiar with the index funtion, but in this case I wish to "reverse" it, i.e. given a reading of the table I would like to know the headeres of the corresponding columns and rows.
    The following shows a correlation matrix, for example. If I were to enter a value 99.8%, I wish to receive the result, "Column A; Row F". I would be happy to calculate the column (A) and row (F) in separate cells, but I just can't find the right approach. I imagine, I have to "twist" the index or indirect function in some way...

    A B C D E
    A
    B 87.4%
    C 83.5% 75.9%
    D 96.5% 82.7% 74.9%
    E 87.6% 98.7% 77.5% 82.1%
    F 99.8% 88.8% 84.6% 95.9% 89.1%


    Can somebody help? For convenience/means of reference we can take the top left corner of the table to be cell A1 in Excel.

    Best regards,
    Excel_Arate
    Attached Files Attached Files
    Last edited by Excel_Arate; 07-23-2020 at 09:26 AM. Reason: Attachment added

  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,647

    Re: Retrieving Table Headers

    There are instructions at the top of the page explaining how to attach your sample workbook.
    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
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Retrieving Table Headers

    Assuming Column headers in range B1:F1, Row headers in A2:A7 range.
    C10 holds 99.80%

    Row:
    =INDEX(A1:A7,SUMPRODUCT((B2:F7=C10)*ROW(B2:F7)))
    =F

    Column:
    =INDEX(A1:F1,SUMPRODUCT((B2:F7=C10)*COLUMN(B2:F7)))
    =A

    See attached.
    Attached Files Attached Files
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  4. #4
    Registered User
    Join Date
    05-25-2017
    Location
    Buchs, Switzlerand
    MS-Off Ver
    2019
    Posts
    75

    Re: Retrieving Table Headers

    Hi CK76, Thank you so much! This is very useful and I could have surfed the web for another year without getting there. Cheers, Excel_Arate

  5. #5
    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,647

    Re: Retrieving Table Headers

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

  6. #6
    Registered User
    Join Date
    05-25-2017
    Location
    Buchs, Switzlerand
    MS-Off Ver
    2019
    Posts
    75

    Re: Retrieving Table Headers

    Hi CK76 (or other interested user),

    The solution provided works fine, but only if the section is not moved around (with or without inserting the "$" signs and also regardless whether I use the formula as an array or not). Your formula works, even without the arrays you have used.

    Please see for yourself. Can you help me understand why this is so?

    Best regards,
    Excel_Arate
    Attached Files Attached Files

  7. #7
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Retrieving Table Headers

    COLUMN(I2:M7) evaluates to...

    {9,10,11,12,13}

    Meaning it's Column Index# for I, J, K, L, M.

    In INDEX function, you would want the Row/Column index to start from 1. So you need to offset the Column/Row range.

    Note that I cheated a bit in the formula I used. Instead of giving offset to ROW/COLUMN, I just started the index range at A1. This effectively serves as offsetting index start from 2.

    If the data range shifts. It's better to use below construct.

    For Row:
    =INDEX(A2:A7,SUMPRODUCT((B2:F7=C10)*(ROW(B2:F7)-ROW(B2)+1)))

    For Column:
    =INDEX(B1:F1,SUMPRODUCT((B2:F7=C10)*(COLUMN(B2:F7)-COLUMN(B2)+1)))

    EDIT: Oh I forgot to mention. I highly recommend using Formula ribbon -> Evaluate formula to see how the formula evaluates.
    Last edited by CK76; 07-24-2020 at 09:31 AM.

  8. #8
    Registered User
    Join Date
    05-25-2017
    Location
    Buchs, Switzlerand
    MS-Off Ver
    2019
    Posts
    75

    Re: Retrieving Table Headers

    Hi CK76,

    For some reason I still can't get this to work. Meanwhile I will close the thread and do some more research on this. Thank you for looking into this.

    Best regards,
    Excel_Arate

  9. #9
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Retrieving Table Headers

    In your sample workbook.

    Paste in the formulas in post#7. Then copy paste into other areas as formula only. You should see reference ranges changing for each to adjust column/row start.

    See attached.
    Attached Files Attached Files

+ 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: 2
    Last Post: 07-23-2018, 12:33 PM
  2. autofilter method of range class failed -header has tables headers and non table headers
    By naveen.acheanz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-16-2016, 08:21 AM
  3. VBA: Fill out column with lookup table refering to table headers
    By AnnaGT in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-02-2015, 03:03 AM
  4. Replies: 1
    Last Post: 03-28-2013, 11:31 AM
  5. Excel 2007 : Retrieving data from multiple table into one table
    By nazruleffendy in forum Excel General
    Replies: 1
    Last Post: 04-20-2010, 12:41 AM
  6. Retrieving Data from a Table
    By cbudrecki in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-23-2009, 02:33 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