+ Reply to Thread
Results 1 to 8 of 8

Is there a way to check if a range contains CVErr values

  1. #1
    Registered User
    Join Date
    03-23-2011
    Location
    West Bromwich, England
    MS-Off Ver
    Excel 2007 & 2013 in Azure
    Posts
    83

    Is there a way to check if a range contains CVErr values

    Hi All,

    We currently import files which may have CVErr values included (eg #N/A). When the data comes to us it contains no formula's and we have no control over the user ensuring no errors exist.

    Some checks are already being performed such as the following for merged cells:
    Please Login or Register  to view this content.

    Is there a similar way to check the range as a whole for any of the CVErr values (not by individual cell due to the size of data)?

    Thanks

    Tooley

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Is there a way to check if a range contains CVErr values

    Tooley

    You could try using SpecialCells to see if there any errors.

    It would return all the cells but it doesn't check them one by one.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    03-23-2011
    Location
    West Bromwich, England
    MS-Off Ver
    Excel 2007 & 2013 in Azure
    Posts
    83

    Re: Is there a way to check if a range contains CVErr values

    Hi Norrie,

    I have the following, which whilst doesn't appear to resolve this specific issue, will be really useful elsewhere so have posted if it benefits others:

    Please Login or Register  to view this content.
    Unless I've done something wrong, the above appears to work if any formulas in the range return a CVError, but not if the range contains no formulas with the errors as values only (eg "#N/A")?

    Thanks

    Tooley

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Is there a way to check if a range contains CVErr values

    Change xlCellTypeFormulas to xlCellTypeConstants
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Is there a way to check if a range contains CVErr values

    Tooley

    I'm not sure I follow, do you want to check if a range has any errors or for specific types of errors or if it has no errors?
    Please Login or Register  to view this content.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Is there a way to check if a range contains CVErr values

    UDF
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-23-2011
    Location
    West Bromwich, England
    MS-Off Ver
    Excel 2007 & 2013 in Azure
    Posts
    83

    Re: Is there a way to check if a range contains CVErr values

    Thanks both, the following now appears to work as I need it too:

    Please Login or Register  to view this content.
    The above uses ErrorHandler label for handled errors as I avoid Resume Next as much as possible and I use an ErrorHandling class for the unhandled errors. Also I haven't attempted to set a test range purely down to preference and consistency with other code. If there are more benefits using the Test range approach, please advise as am always looking to improve.

    Thanks again both
    Last edited by Tooley; 01-23-2018 at 08:53 AM.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Is there a way to check if a range contains CVErr values

    Nothing wrong with using On Error Resume Next as long as you confine it to handling the error you are trying to deal with rather than using it as some sort of all encompassing error handler/hider.

+ 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. Check range for values and return list of found unique values
    By kian82 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-13-2017, 04:45 AM
  2. ?CVErr(xlErrDiv0)
    By intothewild in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-09-2014, 05:38 AM
  3. VBA check values from range with loop
    By Tosters in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 12-11-2013, 06:15 PM
  4. [SOLVED] Check if a range of cells contains values
    By ezzy85 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-05-2012, 01:28 AM
  5. Check range for values
    By KKEOGH in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-01-2011, 01:49 PM
  6. [SOLVED] Q: check a range values
    By JIM.H. in forum Excel General
    Replies: 2
    Last Post: 10-20-2005, 08:05 PM
  7. Type Mismatch with CVErr loop
    By JFamilo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-15-2005, 10:48 AM

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