+ Reply to Thread
Results 1 to 6 of 6

Referencing functions in a function?

Hybrid View

  1. #1
    Registered User
    Join Date
    11-20-2005
    Posts
    33

    Referencing functions in a function?

    Hello everyone. I have another weird one for you.

    I have 6 columns of data. The first 5 columns have data that needs to be looked up and the 6th is the associated "answer." I need to use a vlookup function to find the "answer." In addition, I have a column with a number that is related to which one of the 5 columns vlookup needs to look in to find a match. The cells contain a 1 through 5, which correspond to columns 1 through 5 mentioned above.

    So, I have two worksheets, say A and B. A contains the lookup function, the lookup value, and the number column. Worksheet B contains the 6 columns of data in columns A through F.

    I need vlookup to look up a value and it needs to look in the column associated with the “number column.” For instance, if the number is two, I need the function to look in column B and if its 3, it needs to look in column C. I created a lookup function to associate 1 with A, 2 with B, etc, but I cannot get excel to accept the value of the lookup function as a value in the callout for the lookup array in the vlookup function.

    I suppose I could do 5 lookup functions, array their values, and use the lookup function from there, but it seems inefficient to do it this way because of the 5 required vlookups rather than 1. I am dealing with 20,000 line items, so I don’t want to bog the computer down any more than I have to. Any ideas?

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Referencing functions in a function?

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!

  3. #3
    Registered User
    Join Date
    11-20-2005
    Posts
    33

    Re: Referencing functions in a function?

    Arthur,

    I have created an attached a sample less data. You'll notice that the lookup function in column D in Sheet one is:

    =VLOOKUP(A2,Data!A1:D6,5-Sheet1!B2,FALSE)

    I need to replace the "A" in the "A1:D6" array with the value in column C in Sheet 1 (I called it "Column Reference"

    If that worked, the vlookup equations would be:
    =VLOOKUP(A2,Data!A1:D6,4,FALSE) if the column reference was 1
    =VLOOKUP(A2,Data!B1:D6,3,FALSE) if the column reference was 2
    =VLOOKUP(A2,Data!C1:D6,2,FALSE) if the column reference was 3

    Hopefully it is a little more clear what I am looking for. Thanks for the help!
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor ratcat's Avatar
    Join Date
    03-07-2008
    Location
    Rural NSW, Australia
    MS-Off Ver
    Vista 2007
    Posts
    1,111

    Re: Referencing functions in a function?

    G'day

    Try this

    =VLOOKUP(A2,INDIRECT("Data!$"&C2&"$1:$D$6"),5-Sheet1!B2,FALSE)
    Cheers

    RC
    Have I made you happy ??? If yes, please make me happy by pressing the http://www.excelforum.com/images/buttons/reputation-40b.png Add Reputation button in my post.
    Please don't forget to do the same to other contributors of this forum.

    Thanks
    I don't void confusion, I create it

  5. #5
    Registered User
    Join Date
    11-20-2005
    Posts
    33

    Re: Referencing functions in a function?

    ratcat, works perfectly. Thanks!

  6. #6
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Referencing functions in a function?

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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