Thread: Error Handling
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Kevin Kevin is offline
external usenet poster
 
Posts: 504
Default Error Handling

thanks - works

but what if for instance i want to go to a sheet and ensure it has no
filters (as I want to apply filters from scratch

eg below works only if a filter is applied in the first place
ActiveSheet.ShowAllData
otherwise i get an error
--
Kevin


"Jim Thomlinson" wrote:

The best way to deal with an error is to avoid it in the first place. When
doing a find there is no need to generate the error

Dim rngFound As Range

set rngfound = Sheets("Sheet1").Range("A1:A100").Find(What:="this ", _
LookAt:=xlWhole, _
LookIn:=xlFormulas, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "Sorry... Not Found"
Else
rngfound.select
'do your stuff
end if
--
HTH...

Jim Thomlinson


"Kevin" wrote:

Hi

Is there an easy way to tell ms vb that if an action produces an error
simply to skip several lines and continue. I say because I expect errors in
certain instances (in this case where a Find function cannot find a value
then I just want to the macro to continue (but must skip a few lines on code
which become irrelevant)
--
Kevin