+ Reply to Thread
Results 1 to 8 of 8

How to convert all cells that are "#N/A" (result of vlookup) to a blank cell?

  1. #1
    Registered User
    Join Date
    06-19-2013
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    14

    How to convert all cells that are "#N/A" (result of vlookup) to a blank cell?

    I'm pulling numbers into these cells from another worksheet based on an ID number but when the ID number isn't found on the other worksheet, the cell will appear as "#N/A". Is there a code I can enter into the macro that will convert all cells that are "#N/A" into a blank cell?

    This is what I'm referring to:

    \1

    The last column is the sum of all numbers from the first two columns, but if any cell in the first two columns are "#N/A", then it cannot spit out a number in the last column. So I would like to enter a code in VBA to basically converts any cell that is "#N/A" to a blank cell. How do I do that? Thanks

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

    Re: How to convert all cells that are "#N/A" (result of vlookup) to a blank cell?

    Brookshire,

    I would modify the formula to first check if the LookupValue exists. It would look like this:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

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

  3. #3
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: How to convert all cells that are "#N/A" (result of vlookup) to a blank cell?

    It depends:

    - If it's just a presentation thing then select all of the cells on the sheet, add a conditional format based on cell value, where the value is an error and format the text to white

    - If you're using Excel 2007 you can encase all of your lookups in IFERROR, e.g. =IFERROR(VLOOKUP(A1,B:C,2,FALSE),"")

    - If you're using Excel 2003 you can use ISNA, e.g. =IF(ISNA(VLOOKUP(A1,B:B,1,FALSE)),"",VLOOKUP(A1,B:C,2,FALSE))

    - If you're using MS Paint, as per your example, then just colour over the nasty errors with your white crayon.

  4. #4
    Forum Contributor
    Join Date
    07-24-2012
    Location
    Denver, CO
    MS-Off Ver
    365
    Posts
    230

    Re: How to convert all cells that are "#N/A" (result of vlookup) to a blank cell?

    Please Login or Register  to view this content.
    Just an option
    ~~LaffyAffy13~~

    If I have helped you solve your problem, please be sure to click at the bottom left of my post.

    Thanks.

  5. #5
    Registered User
    Join Date
    06-19-2013
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: How to convert all cells that are "#N/A" (result of vlookup) to a blank cell?

    Quote Originally Posted by Andrew-R View Post
    It depends:

    - If it's just a presentation thing then select all of the cells on the sheet, add a conditional format based on cell value, where the value is an error and format the text to white

    - If you're using Excel 2007 you can encase all of your lookups in IFERROR, e.g. =IFERROR(VLOOKUP(A1,B:C,2,FALSE),"")

    - If you're using Excel 2003 you can use ISNA, e.g. =IF(ISNA(VLOOKUP(A1,B:B,1,FALSE)),"",VLOOKUP(A1,B:C,2,FALSE))

    - If you're using MS Paint, as per your example, then just colour over the nasty errors with your white crayon.
    Well this will be used daily so the numbers that are calculated in the last column need to be correct which means there cannot be any #N/A's in the cells in the first two columns period. If it is not a number, then it needs to be a blank cell.

  6. #6
    Registered User
    Join Date
    06-19-2013
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: How to convert all cells that are "#N/A" (result of vlookup) to a blank cell?

    Quote Originally Posted by tigeravatar View Post
    Brookshire,

    I would modify the formula to first check if the LookupValue exists. It would look like this:
    Please Login or Register  to view this content.
    That Lookupvalue, does that need to be changed for every ID number that is being searched? If so then is there some way I can tweak your formula so that I won't have to re-enter it in each cell whenever the search based ID number is changed?

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

    Re: How to convert all cells that are "#N/A" (result of vlookup) to a blank cell?

    Usually the LookupValue is stored in a cell, and you just have it reference the cell. The cell reference will change automatically as the formula is copied down (or across) as long as you don't use an absolute reference (as long as the cell reference to the lookup values doesn't have $ symbols, e.g. A1 will be fine where $A$1 will not be fine).

  8. #8
    Registered User
    Join Date
    06-19-2013
    Location
    Texas
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: How to convert all cells that are "#N/A" (result of vlookup) to a blank cell?

    Quote Originally Posted by LaffyAffy13 View Post
    Please Login or Register  to view this content.
    Just an option
    Thanks, this worked perfectly.

+ 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. Replies: 6
    Last Post: 09-25-2013, 01:51 PM
  2. Replies: 2
    Last Post: 04-29-2013, 04:20 AM
  3. [SOLVED] Trying to Use ("") to Result in #VALUE Error Cells turning Blank
    By jordan1214 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-23-2013, 01:39 AM
  4. Replies: 8
    Last Post: 12-31-2012, 05:19 PM
  5. display of "result" cell after using 'vlookup' function
    By telugupriyuralu in forum Excel General
    Replies: 6
    Last Post: 01-10-2009, 01:50 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