+ Reply to Thread
Results 1 to 20 of 20

Find Row OR Column Header for a cell in a two way table WITHOUT VBA

  1. #1
    Registered User
    Join Date
    03-23-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    7

    Lightbulb Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    Here's some example data:

    .. A B C
    E 1 4 6
    F 2 5 9
    G 7 3 2

    So let's say I know the number 9 is in the table and I know it's a 3X3 table but I don't know what row OR what column its in, how do I find the row or column (I know that given one you can find the other)? V & H lookups won't work. I don't think Match will work on an array. I ended up splitting data a column at a time to match only the row, but how can I do it all in one formula in one cell?

    Bonus quesetion: The number 2 shows up twice. How could I output row and column for both of them?

    ALL WITHOUT VBA PROGRAMMING!

    Thanks so much for the help!

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    Hi.

    You don't state whether it's possible for a given value to appear more than once in a given row or column, so I've assumed that it isn't.

    With your search value in D1, to return the relevant rows:

    =IF(ROWS($1:1)>COUNTIF(Range1,$D$1),"",AGGREGATE(15,6,ROW(Range1)/(Range1=$D$1),ROWS($1:1)))

    Replace Range1 with your actual range and copy down until you start to get blanks.

    Identical formula for columns but replacing:

    ROW(Range1)

    with:

    COLUMN(Range1)

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    or this way
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    03-23-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    7

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    XOR LX that works perfectly!! Thanks!
    I know that given duplicate values it would just return the first occurrence observed. And then you might have to make another column to handle duplicates where it says if you experience a duplicate you give its new position.
    Would you know how to do that? You already know the address of the first occurance. Can your formula be edited to search a range but ignore a certain cell within the range?

    Thanks!

  5. #5
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    Sounds doable, but could I ask you to present an actual example together with your expected results?

    Regards

  6. #6
    Registered User
    Join Date
    03-23-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    7

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    Hi XOR,

    Attached in an Excel. I am essentially sorting all data based on price and then outputing what is available at each price level. The problem is if I have a duplicate price then the second, third and nth occurance of this duplicate will give the wrong answer.

    Would you know how to get around this?

    Excel attached.

    Thanks!
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    03-23-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    7

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    tim201110 thanks for your Excel. It worked on your provided sample, but when I tried to apply it to my model (move it) I kept getting errors (I tried tweaking the formula and used the CTR+SHIFT+ENTER for arrays as well but nothing worked).

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    Ok, first of all I'm not sure why you've changed the ROWS($1:1) part in my solution to COLUMNS($A:A), since these formulas are intended to be dragged down, not across.

    Secondly, constructions using INDIRECT and ADDRESS are best avoided if possible (which it almost always is) due to their inherent volatility.

    Thirdly, you can employ a COUNTIF construction for AGGREGATE's k parameter to get round the duplicates issue.

    In E21:

    =IF(ROWS($1:$1)>COUNTIF($E$12:$G$17,D21),"",INDEX($E$11:$G$11,AGGREGATE(15,6,COLUMN($E$11:$G$11)-MIN(COLUMN($E$11:$G$11))+1/($E$12:$G$17=D21),COUNTIFS(D$21:D21,D21))))

    In F21:

    =IF(ROWS($1:$1)>COUNTIF($E$12:$G$17,D21),"",INDEX($D$12:$D$17,AGGREGATE(15,6,ROW($D$12:$D$17)-MIN(ROW($D$12:$D$17))+1/($E$12:$G$17=D21),COUNTIFS(D$21:D21,D21))))

    Cheers

  9. #9
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,481

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    How about in E21:

    =INDEX($11:$11,LARGE(IF($E$12:$G$17=$D21,COLUMN($E$12:$G$17),""),COUNTIF($D$21:$D21,$D21)))

    F21:

    =INDEX($D:$D,LARGE(IF($E$12:$G$17=$D21,ROW($E$12:$G$17),""),COUNTIF($D$21:$D21,$D21)))

    Both are array formula must be confirmed by Ctrl-Shift-Enter
    Quang PT

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    @bebo

    Isn't that just identical to mine apart from a few minor details?

    Regards

  11. #11
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,481

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    @XOX LX,
    In fact, I have never used AGGREGATE before, I tried but still not to become its friend...
    I refer to LARGE in this kind of work

  12. #12
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,481

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    There is bug in XOX LX and mine, too:
    If there is value triplicates two rows+two columns in table,i.e: 214 in E14,E15,F14
    throw up all !

  13. #13
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    Quote Originally Posted by bebo021999 View Post
    @XOX LX,
    In fact, I have never used AGGREGATE before, I tried but still not to become its friend...
    I refer to LARGE in this kind of work
    Actually I prefer your idea of INDEXing the entire row/column, which means that the constructions I used for generating the row/column values are not necessary.

    Quote Originally Posted by bebo021999 View Post
    There is bug in XOX LX and mine, too:
    If there is value triplicates two rows+two columns in table,i.e: 214 in E14,E15,F14
    throw up all !
    Can you clarify? I can't see how this is an issue?

    Regards

  14. #14
    Registered User
    Join Date
    03-23-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    7

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    @XOR LX & @bebo
    Bebo as you mentioned both your formulas can handle multiple duplicates if across the same row or column but 3 or more duplicates spread about creates incorrect answers. Can this be avoided?

    @XOR LX
    If I don't use the INDIRECT(ADDRESS) how else would you suggest I get the column/row header?
    Last edited by militiamc; 03-25-2015 at 05:06 PM.

  15. #15
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    Quote Originally Posted by militiamc View Post
    @XOR LX & @bebo
    Bebo as you mentioned both your formulas can handle multiple duplicates if across the same row or column but 3 or more duplicates spread about creates incorrect answers. Can this be avoided?
    Can someone please clarify this issue with an example?

    Quote Originally Posted by militiamc View Post
    @XOR LX
    If I don't use the INDIRECT(ADDRESS) how else would you suggest I get the column/row header?
    With INDEX, as both bebo and I used.

    Regards

  16. #16
    Valued Forum Contributor
    Join Date
    11-22-2014
    Location
    Arizona, USA
    MS-Off Ver
    Office 365
    Posts
    973

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    Can I ask the need to see the cross reference -

    Seems like dropping this into a Pivot would be much simpler, can identify a count of values based on selection in a slicer which in turn can tell you the week, Type, Rate or even sorted (which is an ID) value.

    Could also apply conditional formatting that makes the desired amount pop in an obnoxious color...

    Just curious if this is necessary for what the actual end result is... Perhaps knowing how this will be of use other suggestions/recommendations on how to get to the goal can be brought about...

    Cheers
    -If you think you are done, Start over - ELeGault

  17. #17
    Registered User
    Join Date
    03-23-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    7

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    @XOR LX

    If there at are least 2 duplicates in the same row AND at least 2 duplicates in the same column then the formulas don't work. Please see attached worksheets
    Attached Files Attached Files

  18. #18
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    Ah, yes. Of course. Thanks.

    Perhaps change the formula in F21 to:

    =IF(E21="","",INDEX($D$12:$D$17,AGGREGATE(15,6,ROW($D$12:$D$17)-MIN(ROW($D$12:$D$17))+1/(INDEX($E$12:$G$17,,MATCH(E21,$E$11:$G$11,0))=D21),COUNTIFS(D$21:D21,D21,E$21:E21,E21))))

    though I imagine there are simpler solutions!

    Regards

  19. #19
    Registered User
    Join Date
    03-23-2015
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    7

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    @XOR LX

    Thanks that works perfectly!

  20. #20
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Find Row OR Column Header for a cell in a two way table WITHOUT VBA

    You're welcome!

+ 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 name in a table and return the column header
    By rodgersmg in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-23-2014, 08:59 AM
  2. [SOLVED] Find Row in Table based on Column Header
    By thisguy4000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-18-2014, 12:55 PM
  3. Find first visable cell under header of column A.
    By Chris Acheson in forum Excel General
    Replies: 1
    Last Post: 07-01-2014, 04:17 AM
  4. [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
  5. [SOLVED] Find last non blank cell in a row then return column header
    By Chad B in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-13-2013, 10: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