Program vb to do something in case of an error.

B

bjwoodruff

I have read the tips and googled this problem but I cannot find the
answer to it, so I am looking for your help.

My workbook is programed to copy the contents of one cell and find that
excat match in another workbook. The problem comes up when the macro
cannot find that match in the other workbook so my macro halts stating
error. How can I program my macro to ignore the error of not finding
that item and move on to the next cell.
Thanks to anyone who can help me.

Benjamin Woodruff
 
G

Guest

One way is to set the found cell to a range variable. You can then test the
range variable to see if the contents of your original cell were found.

Something like this:

Dim FindIt As Range
'find lookup value
'switch to other sheet or set a range to test
With Cells ' check all cells or change to set range
Set FindIt = .Find("6995", LookIn:=xlValues)
End With
If Not FindIt Is Nothing Then
'Do whatever you lke with FindIt
End If

Hope this helps
Rowan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top