+ Reply to Thread
Results 1 to 8 of 8

Automate column filling after lookup

Hybrid View

  1. #1
    Registered User
    Join Date
    09-20-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    28

    Automate column filling after lookup

    Please note the problem has changed...The new issue is in a post #6 below. Thanks!
    Hello All,

    I’m not sure if I need to use a lookup or a Macro.
    I have a workbook that contains several columns on one sheetone of which notes “descriptions.” These descriptions vary. On another sheet there are several columns of “categories.”These columns have headers which is what the “descriptions on the first sheetare grouped under. How can I automate grabbing the “header” from sheet two intosheet one after a search is done for the “descriptions” in the individualcolumns on Sheet two?


    I’m looking for a way to automatically fill column 5 withthe headers on sheet 2, (Dogs, cats, fish, pens, metal) IF the description in Column 4 on page one is anywhere on Sheet 2.
    Please help or let me know if this is even possible. Thanks in Advance

    Examples Attached

    fill column.xlsx


    Please note the problem has changed... can someone tell me how to edit the formula to retrun and actual error if the "description" isn't on the list in sheet 2? For some reason it defaults and chooses the last column I was in and enters that in the field if the description isn't found.
    Last edited by gigi79; 11-09-2012 at 01:48 PM.

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Automate column filling after lookup

    In your example
    =INDEX(Sheet2!$A$1:$E$1,SUMPRODUCT((Sheet2!$A$2:$E$5=Sheet1!D2)*COLUMN($A$2:$E$2)))

    SUMPRODUCT(((Sheet2!$A$2:$E$5=Sheet1!D2)*COLUMN($A$2:$E$2)) will return the appropriate column that the description occurs in (from 1 to 5)
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    09-20-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Automate column filling after lookup

    Quote Originally Posted by ChemistB View Post
    In your example
    =INDEX(Sheet2!$A$1:$E$1,SUMPRODUCT((Sheet2!$A$2:$E$5=Sheet1!D2)*COLUMN($A$2:$E$2)))

    SUMPRODUCT(((Sheet2!$A$2:$E$5=Sheet1!D2)*COLUMN($A$2:$E$2)) will return the appropriate column that the description occurs in (from 1 to 5)
    Does that work for you?

    Yes!!!!

    Thank you so much. I have over 1500 lines of data that needed that new column.

    Thanks again!

  4. #4
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Automate column filling after lookup

    Hi gigi79,

    Try using below formula:-


    Formula: copy to clipboard
    {=INDEX(Sheet2!$A$1:$E$1,1,MIN(IF(Sheet2!$A$2:$E$5=Sheet1!$D2,COLUMN(Sheet2!$A$2:$E$5),"")))}


    Enter this using key combination ctrl shift enter..

    see attached:- fill column.xlsx

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), dilipandey@gmail.com

  5. #5
    Registered User
    Join Date
    09-20-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Automate column filling after lookup

    Thanks!!!!

  6. #6
    Registered User
    Join Date
    09-20-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Automate column filling after lookup

    Please note the problem has changed... can someone tell me how to edit the formula to retrun and actual error if the "description" isn't on the list in sheet 2? For some reason it defaults and chooses the last column I was in and enters that in the field if the description isn't found.

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Automate column filling after lookup

    Try

    =IF(SUMPRODUCT((Sheet2!$A$2:$E$5=Sheet1!D2)*COLUMN($A$2:$E$2))=0, "No Match", (INDEX(Sheet2!$A$1:$E$1,SUMPRODUCT((Sheet2!$A$2:$E$5=Sheet1!D2)*COLUMN($A$2:$E$2)))))
    Would that work?

  8. #8
    Registered User
    Join Date
    09-20-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Automate column filling after lookup

    Quote Originally Posted by ChemistB View Post
    Try

    =IF(SUMPRODUCT((Sheet2!$A$2:$E$5=Sheet1!D2)*COLUMN($A$2:$E$2))=0, "No Match", (INDEX(Sheet2!$A$1:$E$1,SUMPRODUCT((Sheet2!$A$2:$E$5=Sheet1!D2)*COLUMN($A$2:$E$2)))))
    Would that work?
    Yes it did...Thanks so much!

+ 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