+ Reply to Thread
Results 1 to 16 of 16

Vlookup to return column header name

  1. #1
    Registered User
    Join Date
    03-30-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    10

    Unhappy Vlookup to return column header name

    Hi,

    I'm currently having a very hardtime with the problem stated on the title.
    Student # Math Science Physics Health History
    123 Passed Passed Passed
    456 Passed Passed Passed Passed Passed
    789 Passed Passed
    987 Passed Passed Passed Passed
    654 Passed Passed Passed
    321 Passed Passed Passed

    I need to look up the student number and will return all the subject passed separated by comma in one cell.

    Please help.

    Thanks in advance!!

  2. #2
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    846

    Re: Vlookup to return column header name

    Sample worksheet might help make it easier to understand the problem and therefore the solution
    galvinpaddy

  3. #3
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Vlookup to return column header name

    Something like this:
    Please Login or Register  to view this content.
    This covers the first 3 subjects so add the last 2


    Edit: the above formula assumes your sample data is in range A1:F7 and the student # you want to get the result for is in H3
    Last edited by Cutter; 04-02-2012 at 05:42 PM. Reason: added explanatory note

  4. #4
    Registered User
    Join Date
    03-30-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Vlookup to return column header name

    Hi,

    Attached is what I got. I need to look up for employee ID and will return all applications on the column header that has "OK" value in row in one cell separated by comma.

    Employee ID AIQUIC AIWCS Prod CAPRI CRUIS DBS DCRS DMS Eexcess EMIS PROD ePRS Prod eStart Prod eUPS Prod EWC EZ Audit iView iworks Prod
    5200309 OK OK OK
    5200306 OK OK OK
    5200307 OK OK OK
    5200305 OK OK OK
    5200257 OK
    Hope you can help me with this.

    Thank you so much in advance.
    Attached Files Attached Files

  5. #5
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Vlookup to return column header name

    What happened to your original problem?

  6. #6
    Registered User
    Join Date
    03-30-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Vlookup to return column header name

    Its the same problem, it's just that instead of subjects, applications are need to be looked up and "OK" is the row value. I have like 80 applications and when I look up the employee number all applications that he has (valued "OK" on rows) will be all shown separated by a comma.

    Hope you can help me with this. It's been 2 weeks and still I can't solve the puzzle.

    thanks so much!!

  7. #7
    Registered User
    Join Date
    03-30-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Vlookup to return column header name

    Hi Forum Guru,

    The above formula you gave works, however, it has limits look up value. The oter results are already inacurate.

    Thanks hope you can help me.

  8. #8
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Vlookup to return column header name

    If you submitted your original problem as a simplified sample of your actual problem you should have indicated that because I'm afraid you over-simplified it. Your original post indicated only 5 headings so the solution I suggested would work (even though the formula I provided was lengthy). Now your actual problem has over 60 headings so the formula is no longer of any value. I think you're going to have to go with a VBA solution and, although I could hack some code together that would achieve the desired result, I think it's best to wait for a VBA expert to respond.

    Edit: I have requested to have someone with VBA skills to have a look at this thread.
    Last edited by Cutter; 04-04-2012 at 04:15 PM.

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Vlookup to return column header name

    A worksheet change event can lookup the code selected and bring over all the matching results. I've added this code to your workbook. I've created a named range called MyIDs on the Data sheet consisting of all the values in column A, just add to the list and the ID selection drop box on the LOOKUP sheet will include all the IDs you have.

    Your results will appear in C2 as you select in B2.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  10. #10
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Vlookup to return column header name

    this will give up to 16 results
    Attached Files Attached Files
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  11. #11
    Registered User
    Join Date
    03-30-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    10

    Unhappy Re: Vlookup to return column header name

    Hi,

    Thank you so much for all the replies.. I really appreciate it.

    Sorry but I'm getting more confuse with all the formulas - so complex for me.

    I have attached the file that I am working with. Hope you can put the formala on where the comment goes "I need all applications to be present here".

    Thanks so much in advance!!

    -- Rodge
    Attached Files Attached Files

  12. #12
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Vlookup to return column header name

    you had changed the name of the worksheet_change macro so it wouldn't work. I changed it back and added some simpler formulas into the table to make the REF01 sheet unnecessary. Now you can use the drop down in C4.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    03-30-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Vlookup to return column header name

    Hi JBeaucaire,

    Thank you so much!! It works this time.. you saved me from getting fired!!

  14. #14
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Vlookup to return column header name

    Well that's good to hear.


    If that takes care of your need, please click Thread Tools above your first post and mark this thread as SOLVED.

  15. #15
    Registered User
    Join Date
    03-30-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Vlookup to return column header name

    Hi,

    May I know whats wrong with this: it's no longer displaying the desired results.

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cell As Range, cFND As Range, c As Range, buf As String

    Application.EnableEvents = False
    If Len([C4]) > 0 Then
    Set cFND = Sheets("Raw Data").Range("$A$2:$A$700").Find([C4].Value, LookIn:=xlValues, LookAt:=xlWhole).EntireRow.SpecialCells(xlConstants)
    For Each c In cFND
    If c.Value = "OK" Then buf = buf & ", " & Sheets("Raw Data").Cells(1, c.Column).Value
    Next c
    End If
    If Len(buf) > 0 Then [C17].Value = Mid(buf, 2, Len(buf)) Else [C17] = ""
    Application.EnableEvents = True

    End Sub


    The formula is based from the attached file on previous comments.

    thanks for your help in advance.

  16. #16
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Vlookup to return column header name

    What is your question? Clearly it WAS working, so you'll have to present actual supporting documentation if you want troubleshooting on your workbook (probably changed in some undescribed way.)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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