Finding Errors using the .Find in VBA
Results 1 to 6 of 6

Thread: Finding Errors using the .Find in VBA

  1. #1
    Board Regular
    Join Date
    Jan 2010
    Posts
    226
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Finding Errors using the .Find in VBA

    Hi All,

    Just need a little help refining my macro. I'm trying to find errors in a column using part of the following script...

    Code:
    Dim rngFound As Range
    
    Set rngFound = Columns("N").Find(What:=IsError, After:=Range("N4"), LookAt:=xlWhole, _
        SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    
    MsgBox rngFound.Address
    I'm trying to find any kind of error, e.g. #VALUE , #N/A, etc. I know that my problem is using "What:=IsError", just not sure what to replace it with?

    Best,
    Ben

  2. #2
    Board Regular
    Join Date
    Sep 2016
    Posts
    2,510
    Post Thanks / Like
    Mentioned
    34 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Finding Errors using the .Find in VBA

    Try using SpecialCells instead of Find.

  3. #3
    Board Regular Michael M's Avatar
    Join Date
    Oct 2005
    Location
    South Western NSW
    Posts
    17,502
    Post Thanks / Like
    Mentioned
    18 Post(s)
    Tagged
    2 Thread(s)

    Default Re: Finding Errors using the .Find in VBA

    Maybe this....highlights the error cells in red

    Code:
    Sub MM1()
        ActiveSheet.Range("N:N").SpecialCells(-4123, 16).Interior.ColorIndex = 3
    End Sub
    Regards
    Michael M
    ---------------------------------------
    The more I learn, the less I seem to know.....A Please and Thank You cost nothing !
    It's easier to debug if we can see the whole macro !
    Home 2007 & 2013

    - Posting guidelines, forum rules and terms of use

    - To download Mr Excel HTML Maker

    - Try searching for your answer first, see how

    - Read the FAQs

    - List of BB codes


    [CODE]Place Your Code Here[/CODE]

  4. #4
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    25,290
    Post Thanks / Like
    Mentioned
    435 Post(s)
    Tagged
    45 Thread(s)

    Default Re: Finding Errors using the .Find in VBA

    Depending on your data
    Code:
    Sub storm925()
       On Error Resume Next
       Range("N:N").SpecialCells(xlFormulas, xlErrors).Interior.Color = vbRed
       Range("N:N").SpecialCells(xlConstants, xlErrors).Interior.Color = vbBlue
       On Error GoTo 0
    End Sub
    This will highlight all errors.
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  5. #5
    Board Regular
    Join Date
    Jan 2010
    Posts
    226
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Finding Errors using the .Find in VBA

    Thanks for the tips, I didn't think about using .SpecialCells() I've been using .Find() for such a long time, kind of forgot about this one. Have a great day! --Ben

  6. #6
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    25,290
    Post Thanks / Like
    Mentioned
    435 Post(s)
    Tagged
    45 Thread(s)

    Default Re: Finding Errors using the .Find in VBA

    Glad we could help & thanks for the feedback
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •