+ Reply to Thread
Results 1 to 8 of 8

vlookup to index/match or match/offset

  1. #1
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,347

    vlookup to index/match or match/offset

    I have a little project I was interested in trying.

    I want to have a macro that converts Vlookups to match/offset or index/match.

    I wonder if anyone here has done it before or can give me a head start on the best way to do it and if I'm going to run into any situations where they cannot be converted.

    So basically you would enter a vlookup formula in one cell (or column) and it would take the formula - read its parts and use them to reconstruct it as one of the other two, and put that formula in a cell next to the origional.
    Last edited by scottiex; 03-12-2015 at 01:26 AM.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: vlookup to index/match or match/offset

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,347

    Re: vlookup to index/match or match/offset

    File attached

    Enter the value in A2 and press a button or key combo and get the result in B2.

    Data is just a random sample in practice it could be any simple usage of vlookup (i.e. no dynamically calculated ranges etc). But I tried to show the vlookups could be done in all sorts of ways.

    If it loops through each row that is a bonus. If it handles cross sheet or cross workbook lookups that is also a bonus but not essential.


    I'm not picky on exactly how the offset/match is written as long as it gives the same result.

    vlookup2.xlsm.

    sorry my comment in the attachment should say
    "enter data in A2-A4 get result in B2-B4"
    not
    "enter data in A2-A4 get result in B2"
    (I should be more careful)
    Last edited by scottiex; 03-12-2015 at 11:53 PM.

  4. #4
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,347

    Re: vlookup to index/match or match/offset

    For some background - in essence this would be an educational tool - showing people with very basic skills (and limited willingness to give you their attention), but familiarity with vlookup - how to do this methodology with their own examples (without anyone needing to watch them or explain anything).

    They just throw the formula they are currently using in and it converts it (like I might be able to do if I was there standing next to them).

    I might extend the strategy to other formula too once I see how someone would do it. I could try to do it myself but it I think I'd be using very poor methodology.
    Last edited by scottiex; 03-13-2015 at 06:21 PM.

  5. #5
    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
    53,048

    Re: vlookup to index/match or match/offset

    A few questions/observations...

    1. why? why not just show them how a vlookup works, and how index/match works? And more importantly, when (and why) to use which?
    2. You do know that if you enter 33 in D2, the formulas in A2:B3 return an error?
    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

  6. #6
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,347

    Re: vlookup to index/match or match/offset

    Quote Originally Posted by FDibbins View Post
    A few questions/observations...

    1. why? why not just show them how a vlookup works, and how index/match works? And more importantly, when (and why) to use which?
    2. You do know that if you enter 33 in D2, the formulas in A2:B3 return an error?
    1. Yes I suggested doing that (releasing training documents), but that and other simple options were frustrated by various factors.
    2. Yes because you'd have to change the vlookup range to lookup 33 on the table otherwise it looks for 33 in the first column of the vlookup table.
    I didn't mean to make it confusing - just to give some varied test cases.

    I can write up some logic. If I want to go between these two below (an offset slightly modified to make it more logical) I could just go

    =VLOOKUP($D$2,$F$2:$H$6,3,FALSE)
    =OFFSET($F$2,MATCH($D$2,$F$2:$F$6,FALSE)-1,3-1)

    now pull those formula into vba -
    add on beginning after the = "offset(y" where y = first cell in range
    replace vlookup with match
    second letter in range is changed to match first letter ($H$6 -> $F$6)
    add -1 before vlookup offset
    add -1 after vlookup offset

    I think that has it covered unless I missed something . Might be even simpler if I switch to RC reference style for the editing...

    Now I imagine I'm using split on multiple delimiters (:and,) and replace in vba then reconstruct from the array.

    So I get the array below and then reconstruct it
    =VLOOKUP($D$2
    $F$2
    $H$6
    3
    FALSE)

    But I haven't used that before... I'll start on some research for now.
    Last edited by scottiex; 03-14-2015 at 06:11 AM.

  7. #7
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,347

    Re: vlookup to index/match or match/offset

    this seems to work OK (I will test it a bit more).
    First section is chip persons SplitMultiDelims code to make life easier.


    Please Login or Register  to view this content.
    Last edited by scottiex; 03-16-2015 at 06:12 PM.

  8. #8
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,347

    Re: vlookup to index/match or match/offset

    and for what its worth offsetmatch

    this version doesn't handle fixed ranges ($) - the first one makes all ranges fixed.

    Please Login or Register  to view this content.
    Last edited by scottiex; 03-16-2015 at 06:14 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. INDEX MATCH MATCH/OFFSET MATCH MATCH with named ranges
    By Andrew-Mark in forum Excel General
    Replies: 3
    Last Post: 02-27-2015, 10:56 PM
  2. Replies: 2
    Last Post: 03-16-2012, 12:03 PM
  3. Index, Match, Vlookup, or Offset?
    By karstens in forum Excel General
    Replies: 2
    Last Post: 01-24-2011, 12:46 PM
  4. offset,match,index & vlookup
    By mingali in forum Excel General
    Replies: 1
    Last Post: 01-17-2010, 12:31 PM
  5. Which to use - if, vlookup, match, index, offset, vba?
    By punsterr in forum Excel General
    Replies: 3
    Last Post: 06-07-2005, 02:42 PM

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