+ Reply to Thread
Results 1 to 5 of 5

vlookup values

  1. #1
    Registered User
    Join Date
    03-23-2005
    Posts
    45

    vlookup values

    Hello! I have a formula in a macro, which is looking up an account number from spreadsheet A in spreadsheet B, and bringing back the address. If there is not an address on spreadsheet B for a particular account, then the formula is returning a "0", instead of NULL. How do I tell my formula to return a Null instead of a 0? Thank you for your help!

    Here is my formula:
    ActiveCell.FormulaR1C1 = _
    "=VLOOKUP(RC[-2],[address.xls]Sheet1!R2C1:R65536C12,6,FALSE)"

  2. #2
    Registered User
    Join Date
    08-13-2004
    Posts
    46
    Maybe if you nest the statement in an if statement like this:

    =if(VLOOKUP(RC[-2],[address.xls]Sheet1!R2C1:R65536C12,6,FALSE)=0, "" , VLOOKUP(RC[-2],[address.xls]Sheet1!R2C1:R65536C12,6,FALSE))

    you can replace"" with "NULL" if you want

  3. #3
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    You need to add an IF statement to check for NULL (I assume a blank cell) and return a blank.

    =IF(VLOOKUP(RC[-2],[address.xls]Sheet1!R2C1:R65536C12,6,FALSE)="","",VLOOKUP(RC[-2],[address.xls]Sheet1!R2C1:R65536C12,6,FALSE)

    HTH
    Bruce
    The older I get, the better I used to be.
    USA

  4. #4
    Registered User
    Join Date
    03-23-2005
    Posts
    45
    swats and elue -
    I tried both of your formulas, and in each case my macro errored out. the error I am getting is

    Run-time error 1004:
    Application-defined or Object-defined error

  5. #5
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    without seeing your entire macro I don't know, but do you have an "On Error Resume" statement?

+ 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