Finding Errors using the .Find in VBA

storm925

Board Regular
Joined
Jan 20, 2010
Messages
226
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
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Maybe this....highlights the error cells in red

Code:
Sub MM1()
    ActiveSheet.Range("N:N").SpecialCells(-4123, 16).Interior.ColorIndex = 3
End Sub
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,331
Members
452,636
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top