+ Reply to Thread
Results 1 to 7 of 7

need help fixing vlookup script and adding second step

  1. #1
    Forum Contributor
    Join Date
    09-12-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    127

    need help fixing vlookup script and adding second step

    attached is a sample file where I am trying to assign a name in column A based on a vendor name in column B, the majority of the first step works fine except if the vendor name starts with a numeric character. Can some one offer a better method to achive what I am looking for? I listed the desired results in column G. I basically need to know how to get the lookup to work correctly for vendor names that start with a number( like on row 53) and create a second step to replace the names in column A based on the criteria in cells I24:J27 on the 'APDir' tab.

    s4
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: need help fixing vlookup script and adding second step

    Hi

    The following UDF, invoked as
    Sheet2!C2: =myfunc(B2,APDir!$I$24:$I$27,APDir!$I$13:$J$20)

    returns the correct results except for row 9 where it brings back Jody whereas you have Lupita. Can you please give more detail on how the Mf is to be interpreted.


    Please Login or Register  to view this content.
    rylo

  3. #3
    Forum Contributor
    Join Date
    09-12-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    127

    Re: need help fixing vlookup script and adding second step

    if the first two letters of the vendor name starts with Me it should be Jody if they start with Mf -Mz it should be Lupita, that's why i look at the first two left characters of the vendor name in this line.

    Found.Offset(, 0).Value = WorksheetFunction.VLookup(Left(Found.Offset(, 1), 2), Rng1, 2, True)

  4. #4
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: need help fixing vlookup script and adding second step

    Hi

    OK, then change the function code to
    Please Login or Register  to view this content.
    Works for all the example items except for row 53, and when I did an edit / save on APDir!I13, it worked for that item as well.

    rylo

  5. #5
    Forum Contributor
    Join Date
    09-12-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    127

    Re: need help fixing vlookup script and adding second step

    thanks, is there a way to use that function in my macro? when I try to implement it in my macro i get a run time error 438, object doesn't support this property or method.

    Found.Offset(, 0).Value = WorksheetFunction.myfunc(Found.Offset(, 1), Rng1, Rng2)
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 04-22-2013 at 11:43 PM. Reason: Added Code Tags

  6. #6
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: need help fixing vlookup script and adding second step

    Hi

    OK, I opened the example file from #1, selected cell APDir!I13, F2, Enter.

    Then I made sure that myfunc and the macro above were both in a general module in that workbook.

    I changed the line
    Please Login or Register  to view this content.
    to be

    Please Login or Register  to view this content.
    as it isn't an inbuilt worksheetfunction.

    It put a result into Sheet2!A53, but then errored out - probably because of the disconnect between the filled column A, and the full column B being actioned.

    However, why not put in the function directly. If you don't want the function left, then have the macro run it directly into the cell(s) required, then value paste the results.

    rylo

  7. #7
    Forum Contributor
    Join Date
    09-12-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    127

    Re: need help fixing vlookup script and adding second step

    good idea, I will take that approach. thanks again.

+ 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