Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Error handling

I have this simple program that captures a string and then jumps
to another sheet to look for that string. It works most of the but
causes an annoying error when "findThis" is not on the target sheet.
I have tried various "On Error GoTo . . ." with no success.

Sub FindThis()
'
Dim FindThis As String
FindThis = ActiveCell.Text
Sheets("Box Log").Select
Cells.Find(What:=FindThis, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
'
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Error handling

The easiest may be to use "On Error Resume Next":

On Error Resume Next
....your code here
if Err.Number 0 then
'log message
end if
On Error Goto 0

Bill Barclift


"John Pierce" wrote in message
om...
I have this simple program that captures a string and then jumps
to another sheet to look for that string. It works most of the but
causes an annoying error when "findThis" is not on the target sheet.
I have tried various "On Error GoTo . . ." with no success.

Sub FindThis()
'
Dim FindThis As String
FindThis = ActiveCell.Text
Sheets("Box Log").Select
Cells.Find(What:=FindThis, After:=ActiveCell, LookIn:=xlFormulas,

LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,

MatchCase:= _
False).Activate
'
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Error handling

Sub FindThis()
'
Dim rng as Range
Dim FindThis As String
FindThis = ActiveCell.Text
Sheets("Box Log").Select
set rng = Cells.Find(What:=FindThis, After:=ActiveCell, _
LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:= _
False)
if not rng is nothing then
rng.Select
end if
'
End Sub

--
Regards,
Tom Ogilvy


John Pierce wrote in message
om...
I have this simple program that captures a string and then jumps
to another sheet to look for that string. It works most of the but
causes an annoying error when "findThis" is not on the target sheet.
I have tried various "On Error GoTo . . ." with no success.

Sub FindThis()
'
Dim FindThis As String
FindThis = ActiveCell.Text
Sheets("Box Log").Select
Cells.Find(What:=FindThis, After:=ActiveCell, LookIn:=xlFormulas,

LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,

MatchCase:= _
False).Activate
'
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Handling Kevin Excel Discussion (Misc queries) 4 June 19th 08 12:31 AM
Handling #NUM! error Michel Khennafi Excel Worksheet Functions 1 February 26th 07 08:49 PM
Error handling in this code L. Howard Kittle Excel Discussion (Misc queries) 4 October 8th 05 12:35 PM
Error Handling Rob Bovey Excel Programming 0 August 7th 03 12:11 AM
Error Handling Bill Lunney Excel Programming 0 August 6th 03 11:56 PM


All times are GMT +1. The time now is 08:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"