+ Reply to Thread
Results 1 to 5 of 5

Deleting #N/A from Cell Values VBA or formula help please

  1. #1
    Forum Contributor
    Join Date
    06-13-2009
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    245

    Smile Deleting #N/A from Cell Values VBA or formula help please

    Hello, could someone please help me with a formula for Excel 2003 to do the following:

    Workbook name: C-27J Outstanding Spares Requisitions

    Worksheet name: Master_List

    Column: Z

    Range: Z3:Z1000

    I need a formula or VBA code to delete all instances of any cell value with #N/A.

    Any help would be greatly appreciated.

    Kind regards,

    Chris

  2. #2
    Forum Expert
    Join Date
    11-26-2013
    Location
    Colac, Victoria, Australia
    MS-Off Ver
    Excel 2016
    Posts
    1,309

    Re: Deleting #N/A from Cell Values VBA or formula help please

    Hi Chris,

    A couple of questions:
    1. Does the workbook you want to scan have a formula that produces the #N/A result, or are you importing the data that way?
    2. Does it matter that the cell will be blank? (You will no longer have the formula in place).

    Have you considered changing the formulas which give the #N/A result?

    Since you are using XL2003, you need to use an IF(ISNA...) or IF(ISERROR...) combination. This way, you can force excel to return whatever you want - usually 0 or nul.

    I hope this helps, please let me know!

    Regards,

    David


    - Please click on the *Add Reputation button at the bottom of helpful responses.

    Please mark your thread as SOLVED:
    - Click Thread Tools above your first post, select "Mark your thread as Solved".


  3. #3
    Forum Contributor
    Join Date
    06-13-2009
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    245

    Re: Deleting #N/A from Cell Values VBA or formula help please

    Hi David, thank you for your reply - much appreciated.

    The workbook I have does not have any formulas. It does not matter that the cell will be left blank. I am trying to use a SUMPRODUCT function in the range Z3:Z1000 and it does not like any cells with #N/A in them. The SUMPRODUCT function is: =SUMPRODUCT(--($G$3:$G$1000="AOG"),--($Z$3:$Z$1000>0))

    When I delete all instances of #N/A from the range Z3:Z1000, my SUMPRODUCT function gives me the correct result.

    The data in column Z originally came from a VLOOKUP function from another worksheet named: Buy_Summary

    The formula I use is: Range("Z3:Z10000").Formula = "=VLOOKUP(B3,Buy_Summary!$A$4:$R$10000,17,False)"

    After which I change the formula result into a value by using the following VBA code:

    Columns("Z:Z").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("A2").Select
    Application.CutCopyMode = False
    Range("A3").Select

    These formulae/code are in a macro.

    From my understanding of what you are saying, is that I may be able to modify my VLOOKUP formula with IF(ISNA...) or IF(ISERROR...)?

    I hope this helps - if not please let me know.

    Kind regards,

    Chris

  4. #4
    Forum Expert
    Join Date
    11-26-2013
    Location
    Colac, Victoria, Australia
    MS-Off Ver
    Excel 2016
    Posts
    1,309

    Re: Deleting #N/A from Cell Values VBA or formula help please

    Hi Chris,

    I think you could make the following change to the code that creates the source value in Column Z.

    =IF(ISERROR(VLOOKUP(B3,Buy_Summary!$A$4:$R$10000,17,False)),"",VLOOKUP(B3,Buy_Summary!$A$4:$R$10000,17,False))

    This will place a blank cell (nul from the "") where the value in B3 is not found instead of the #N/A. This should solve the problem.

    Alternatively, in your macro you could add this bit of code just after you do the paste - :
    Please Login or Register  to view this content.
    I haven't tested it, but I think the selected range will be "held" after the PasteSpecial command.

    This should replace all the #N/A's.

    I hope this helps, please let me know!

    Regards,

    David


    - Please click on the *Add Reputation button at the bottom of helpful responses.

    Please mark your thread as SOLVED:
    - Click Thread Tools above your first post, select "Mark your thread as Solved".


  5. #5
    Forum Contributor
    Join Date
    06-13-2009
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    245

    Re: Deleting #N/A from Cell Values VBA or formula help please

    Thanks David A Coop - greatly appreciated. I ended up doing what you suggested with the find and replace code using the Excel macro recorder. Also, thank you for the suggested:

    =IF(ISERROR(VLOOKUP(B3,Buy_Summary!$A$4:$R$10000,17,False)),"",VLOOKUP(B3,Buy_Summary!$A$4:$R$10000,17,False))

    formula. This will be very handy and useful.

    Kind regards,

    Chris

+ 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: 1
    Last Post: 10-09-2015, 09:19 AM
  2. Deleting cell values, but not forumlas?
    By fleetwood417 in forum Excel General
    Replies: 2
    Last Post: 08-24-2013, 04:05 PM
  3. [SOLVED] Deleting Rows & Formula Values (#REF!)
    By thalantyrdsl in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-14-2013, 07:09 AM
  4. deleting duplicates of both cell values
    By bjno8 in forum Excel General
    Replies: 6
    Last Post: 09-09-2008, 02:33 PM
  5. Deleting Cell Values
    By aaser018 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-10-2007, 12:07 PM
  6. [SOLVED] Deleting cell values
    By watkincm in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-18-2006, 10:00 AM
  7. how prevent formula in cell from deleting when deleting value????
    By sh-boom in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 09-30-2005, 02:05 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