+ Reply to Thread
Results 1 to 4 of 4

Applying IF function to a custom vlookup formula

  1. #1
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Applying IF function to a custom vlookup formula

    Hi everyone,

    THis one might be a bit tricky. Using VBA code if found on the internet, I've created a custom vlookup VBA for cells over 255 characters:

    =MyVL(AM3,PA!$L:$Y,13)

    The macro code is:

    Function MyVL(v As Range, r As Range, os As Long) As Variant
    Dim cl As Range

    For Each cl In r.Columns(1).Cells
    If v = cl Then
    MyVL = cl.Offset(0, os - 1)
    Exit Function
    End If
    Next
    End Function

    What I need to do is add an if statement which will sure cell to the left the cell with the MyVL formula. What I need it to do is return a BLANK value if the cell to the left of the one with the formula is either a 0, blank or #REF!. Any ideas?

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Applying IF function to a custom vlookup formula

    Assuming your formula is in AN3 (so looking in AM3)

    =IF(ISERROR(AM3),"",IF(AM3, MyVL(AM3,PA!$L:$Y,13), ""))
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: Applying IF function to a custom vlookup formula

    Hi Chemist,

    Thanks very much. I tried your formula but it blanks out all cells, even ones with adjacent values in them. Now, the adjasent cells have text values because of a vlookup in them. Would that make a difference?

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Applying IF function to a custom vlookup formula

    Hmmm, try

    Formula: copy to clipboard
    Please Login or Register  to view this content.

+ 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. [SOLVED] Custom Number format not applying correctly
    By rasonline in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-17-2013, 06:22 AM
  2. [SOLVED] Applying the INDIRECT or INDEX function on formula to solve #REF issue
    By Flight777 in forum Excel General
    Replies: 23
    Last Post: 05-24-2012, 09:23 AM
  3. Custom Vlookup function
    By Stėophan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-02-2007, 06:48 PM
  4. [SOLVED] Custom function to simplify vlookup formula
    By John James in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2006, 05:45 PM
  5. [SOLVED] Custom Function VLookup
    By Martin in forum Excel General
    Replies: 1
    Last Post: 03-15-2006, 04:35 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