+ Reply to Thread
Results 1 to 9 of 9

VLOOKUP from right to left in closed workbook - not possible? Any alternative?

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    VLOOKUP from right to left in closed workbook - not possible? Any alternative?

    Sorry this is a long one. (You could jump to Question 1 but the Background info may help to understand what I am trying to achieve).


    BACKGROUND:
    I have a workbook which is data-connected to files from another program (I'll call this DATA WORKBOOK from now on). On a certain sheet, I have a list of employer names in Column B. In Column A I have a list of ID numbers (which are used to refer to an employer). I can't change the column order of this sheet as the data is connected to an external source and I don't want to risk compromising the data.

    I am currently creating a form in another workbook (for sake of reference I'll call this PROJECT WORKBOOK). This form has code which looks up the Employer names in DATA WORKBOOK, and uses that to fill a list box.

    Now for the problem. I need to somehow use the employer name (selected by the end user in the form in PROJECT WORKBOOK) to obtain the matching employer ID from DATA WORKBOOK.

    But how do I do it?

    QUESTION 1:
    I was thinking of using a VLOOKUP on the closed DATA WORKBOOK. But AFAIK it is impossible to VLOOKUP when the matching data is not in the left most column. Unless someone knows otherwise? (i.e. I would have to return a value from Column A where the listbox.value matches data in Column B).

    QUESTION 2:
    Would it be possible to create an array from the DATA WORKBOOK, switch the columns in the array and then vlookup the array instead?
    Last edited by mc84excel; 05-02-2013 at 01:29 AM. Reason: edit thread title to more accurately reflect question
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: VLOOKUP from right to left - not possible, right? Any alternative method?

    "it is impossible to VLOOKUP when the matching data is not in the left most column".

    One solution here [Tip #4] (and many other workarounds for common thing we want to do with VLookup but thought it wasn't possible).

    Let me know if this resolves your issues.

    abousetta
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: VLOOKUP from right to left - not possible, right? Any alternative method?

    Quote Originally Posted by abousetta View Post
    Let me know if this resolves your issues.
    Wow. That formula is impressive. I never thought that would be possible.

    However it is not working for me. I get a syntax error message when trying to run it.

    Below is the code. The first intTemp doesn't work due to reading right to left. The second intTemp is based on tip 4 but it's not working?

    Please Login or Register  to view this content.
    Last edited by mc84excel; 05-01-2013 at 11:49 PM.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: VLOOKUP from right to left - not possible, right? Any alternative method?

    As an alternative to the fancy vlookup, you can always use the index/match combination.

    =index(range,row,column)
    =index(range,match(what_you_want_to_find,column/range_to_search,0),match(what_you_want_to_find,roow/range_to_search,0))
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: VLOOKUP from right to left - not possible, right? Any alternative method?

    Hello FDibbins

    Thank you for your suggestion.

    I am aware of the INDEX & MATCH combo as a superior alternative to VLOOKUP. But how would I get this to work in VBA to look up a closed workbook?

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: VLOOKUP from right to left - not possible, right? Any alternative method?

    ok understood, good luck

  7. #7
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: VLOOKUP from right to left - not possible, right? Any alternative method?

    I'm not really good with worksheet formulas in vba. I've trying to make it work in vba but no luck. Works fine as in a worksheet but can't make the conversion work. Hopefully another member of the community can be of more help.

    abousetta

  8. #8
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: VLOOKUP from right to left - not possible, right? Any alternative method?

    I am marking the thread as as solved.

    See this thread for the solution: http://www.excelforum.com/excel-prog...vba-array.html

  9. #9
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VLOOKUP from right to left in closed workbook - not possible? Any alternative?

    you can't use application.worksheetfunction with a closed workbook because you have no range object to pass it. your options would be to open the workbook or use a blank cell and actually enter a formula into it or perhaps use evaluate (although when you have to include a path it's real easy to exceed the 255 character limitation)
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ 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