+ Reply to Thread
Results 1 to 10 of 10

VLOOKUP values only if there is blanks cell

  1. #1
    Forum Contributor
    Join Date
    08-31-2010
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    204

    VLOOKUP values only if there is blanks cell

    Hi all, I am working with vlookup on below scenario and curious if there is a better way to do this..I run a macro which populates

    3 columns
    5,000 rows (4,000 rows contain the data I need, but 1000 is missing identifier in column A..also my total number of rows will change daily)

    I need to do a VLOOKUP (or perhaps there is another option? Lookup?) to find values for Blank cells in Column A based per static data table I have in Sheet3..if nothing is found to return comment "missing variable"

    I was thinking of autofiltering for blanks and doing vlookup then? Is this the most efficient way to approach this?

    Any suggestions much appreciated

    Thanks so much
    Dan

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VLOOKUP values only if there is blanks cell

    Stated differently...

    1) You have a VLOOKUP() formula that searches column A and returns values from adjacent columns.
    2) Sometimes the VLOOKUP does not find the value in column A due to missing values in that column
    3) Would like the VLOOKUP to not return an error when that happens, return "missing variable" instead


    Is this correct?

    If so, you'll need to run the formula twice to check for errors. If your current VLOOKUP is:

    =VLOOKUP(A1, Sheet1!A:C, 3, 0)

    ...you would have to try something like:

    =IF(ISERROR(VLOOKUP(A1, Sheet1!A:C, 3, 0)), "missing variable", VLOOKUP(A1, Sheet1!A:C, 3, 0))
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    08-31-2010
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    204

    Re: VLOOKUP values only if there is blanks cell

    Hi JBeaucaire, all your assumptions below are correct and the formula works fine.. there is another part that is missing though:

    Let's say Column A has 5,000 rows: I already have some filled in identifiers(let's say random 4,000 rows) and I basically just need to scan for any blanks and then do VLOOKUP on those blank cell.. this way I avoid doing VLOOK up for all 5,000 rows and just on the blank ones...and then ofcourse if VLOOKUP does not find the variable from the static table to return "missing variable"

    Hope this make sense

    Dan
    Last edited by donyc; 03-29-2011 at 09:55 AM.

  4. #4
    Forum Contributor
    Join Date
    08-31-2010
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    204

    Re: VLOOKUP values only if there is blanks cell

    I tried to use =if(cell="","",use my vlook up formula)

    but, I can't seem to figure out how to implement it so it starts at A3( there has to be a starting point for this to work I assume?) and scans all the way down to last row which I define:
    LastRow = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VLOOKUP values only if there is blanks cell

    You show formulas and VBA code. What is happening here?

    =IF(A1="", "", VLOOKUP(A1, Sheet1!$A$3:$C$1000, 3, 0))

  6. #6
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: VLOOKUP values only if there is blanks cell

    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  7. #7
    Forum Contributor
    Join Date
    08-31-2010
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    204

    Re: VLOOKUP values only if there is blanks cell

    so I got this one to work:
    Please Login or Register  to view this content.
    but I am trying to edit formula so it now comments if nothing was found but getting error in formula and it highlights my comment as a break: ""not in static instrument table


    Please Login or Register  to view this content.

    Any suggestions why this might be getting stuck?

    thanks
    Dan

  8. #8
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: VLOOKUP values only if there is blanks cell

    When you want the result to be a comment, it only needs one quotation mark around it, not two:

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    08-31-2010
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    204

    Re: VLOOKUP values only if there is blanks cell

    tried single quotes as well..didn't work..clueless what might be the problem here
    any suggestions would be appreciated

  10. #10
    Forum Contributor
    Join Date
    08-31-2010
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    204

    Re: VLOOKUP values only if there is blanks cell

    to clarify when I use the below.. where there is nothing to look up I get value returned of 0 instead of "not in static instrument"

    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)

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