+ Reply to Thread
Results 1 to 9 of 9

Excel 2007 : Allow Vlookup's range to start at the nth occurence of a text value

  1. #1
    Forum Contributor
    Join Date
    09-13-2011
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    111

    Smile Allow Vlookup's range to start at the nth occurence of a text value

    Is there a way to modify the range criteria within the Vlookup function to start at the n-th occurence of a text value?

    Due to my industry, I am not allowed to use VBA.

    What I am trying to do is have vlookup start when the text value "x" shows up for the second time in a column. For instance, there are two sets of data tables on one worksheet, the data sets are on top of each other and seperated by a common heading. The left most heading title is "Name". And, the tables depths are always changing. So a vlookup function that can start at the second occurance of "Name" will allow the function to work dynamically with the given data. The end range value is unimportant, because I can always put some random big number. Such as Ax:A1000, where "x" is the row number of the second occurence of "Name".

    Any help on this would be great. Thanks a bunch.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Allow Vlookup's range to start at the nth occurence of a text value

    This will start the vlookup 1 cell below the occurrence of the first match to what is in say H1....

    =VLOOKUP(H1,INDEX(D1:D25,MATCH(H1,D1:D25,0)+1):E25,2,0)

    so it looks for the H1 value in D1:D25 starting from the cell after the first match to H1, and returns from second column.

    Does that work for you?
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Contributor
    Join Date
    09-13-2011
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    111

    Re: Allow Vlookup's range to start at the nth occurence of a text value

    You're awesome. Thanks NBVC.

  4. #4
    Forum Contributor
    Join Date
    09-13-2011
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    111

    Re: Allow Vlookup's range to start at the nth occurence of a text value

    Okay, so I've run into a little bug. The Index(Match) is turning into #VALUE! when Vlookup tries to use the outcome of Index(Match). I think the problem is that I'm pulling data from a different worksheet.

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Allow Vlookup's range to start at the nth occurence of a text value

    You need to reference the sheetname in the formula

    e.g.

    =VLOOKUP(H1,INDEX('Sheet 2'!D1:D25,MATCH(H1,'Sheet 2'!D1:D25,0)+1):'Sheet 2'!E25,2,0)

    Also, if you don't have a 2nd match, you will get an error too.

  6. #6
    Forum Contributor
    Join Date
    09-13-2011
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    111

    Re: Allow Vlookup's range to start at the nth occurence of a text value

    Ahhhhhhh, I didn't reference the worksheet in the closing range value :'Worksheet 2'!E25. I had :E25. Lol, you rock, thanks!

  7. #7
    Registered User
    Join Date
    11-24-2011
    Location
    Melbourne
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Allow Vlookup's range to start at the nth occurence of a text value

    Hi,

    I'm having trouble adapting this formula to my spreadsheet and I'm not sure I'm doing the right thing. I'd really appreciate some help.

    I have two tables stacked on top of each other; the number of entries in each table changes from month to month, which is why I need a dynamic vlookup.

    In Column A I have a bunch of titles. The first table is headed "Yes" (Cell A1) and the second table is headed "Possible" (for this month, Cell A42, but it will be a different row next month).

    In Column B I have a bunch of values (the number of times the titles were counted that month).

    As an example:

    A B
    Yes 10
    e 5
    d 4
    f 1
    Possible 12
    s 8
    e 3
    r 1

    I want the Vlookup to start its range right after the word Possible, to find a particular title from Column A, and to report the number of titles for that month (so the number in Column B). So for example, I'd be trying to find the value 3 if I were looking up title "e."

    I've modified your formula to:

    =VLOOKUP(L10,INDEX(A:B,MATCH(L4,A:B,0)+1):L4,2,0)

    Where L10 holds name of the particular title I'm looking up (eg "e" from the example above), AB are obviously the columns contaning all my data, and L4 contains the word Possible (separately to column A becuase I can't identify the cell within Column A itself as it changes every month and I don't want people to have to search for it).

    I currently get a value of #N/A. :-(

    I am very new to this and clearly don't know what I'm doing! I'd really appreciate your help.

  8. #8
    Registered User
    Join Date
    11-24-2011
    Location
    Melbourne
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Allow Vlookup's range to start at the nth occurence of a text value

    I'm not sure if you'll see this message as this thread is quite old, but I will cross my fingers anyway!

  9. #9
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Allow Vlookup's range to start at the nth occurence of a text value

    fuzzycells,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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