I have two errors that are possible when running my code. The first is a common error in which my .Find method can't find anything, and I'd like it to resume next if this happens. It's a completely normal occurrence, and I need to leave it in for my manager to approve the code (legacy VBA code is still used and he's scared to change it.
I'd like to specify that if this error is seen then to do nothing, but if it's a specific other error to flag it and be handled by a more robust error handling.
The error I'd like to "ignore" (as in Resume Next or GoTo a specific place in the rest of the code without worrying about the error, I'm not worried about further down the code) is Runtime Error 91. Specifically in the code:
toFindCell1 = Cells.Find(nameVar).Row
where nameVar changes based on a for statement going down a list. I plan to then check it against existing information and use that variable to determine whether or not it exists. If it doesn't, then it will add it.
How can I specify the error I want to handle in VBA?
toFindCell1? In order to properly answer this, we'd need to see more code than the line you want to suppress an error on. Otherwise, your next question will most likely be "why doesn't X work now that I ignore a.Finderror". - Comintern.Findresult to aRange, and then test to see if it isNothing. Using error handling for flow control is overly complicated for what you want to do here. The error 91 is because.FindreturnsNothingand then you try to use the return value without testing it. - Comintern