Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 190
Default I want to trap an error I get in a macro

Hello,

I am trying to show some values using msgbox after using FIND. But when I
try to find a value that does not exist in the sheet I get an error:
Run_time: "91"


h = InputBox("Type number of holes to find")

For X = 1 To h

np = InputBox("type the name of the hole:")

Cells.Find(What:=np, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate

N = ActiveCell
L = ActiveCell.Offset(0, 1)
S = ActiveCell.Offset(0, 2)

MsgBox ("Pozo:" & " " & N & " " & "Linea:" & " " & L & " " &
"Serial:" & " " & S)

End If

Next

How can I trap this run-time error?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default I want to trap an error I get in a macro

Mary,

You should google "On Error Resume Next" and "On Error GoTo". I think
this is what you're looking for.

Regards,

Mary wrote:
Hello,

I am trying to show some values using msgbox after using FIND. But when I
try to find a value that does not exist in the sheet I get an error:
Run_time: "91"


h = InputBox("Type number of holes to find")

For X = 1 To h

np = InputBox("type the name of the hole:")

Cells.Find(What:=np, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate

N = ActiveCell
L = ActiveCell.Offset(0, 1)
S = ActiveCell.Offset(0, 2)

MsgBox ("Pozo:" & " " & N & " " & "Linea:" & " " & L & " " &
"Serial:" & " " & S)

End If

Next

How can I trap this run-time error?

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default I want to trap an error I get in a macro

h = InputBox("Type number of holes to find")

For X = 1 To h

np = InputBox("type the name of the hole:")

Set Cell = Cells.Find(What:=np, _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
If Not Cell Is Nothing Then
N = Cell.Value
L = Cell.Offset(0, 1).Value
S = Cell.Offset(0, 2).Value

MsgBox ("Pozo:" & " " & N & " " & "Linea:" & _
" " & L & " " & "Serial:" & " " & S)
End If

Next


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Mary" wrote in message
...
Hello,

I am trying to show some values using msgbox after using FIND. But when I
try to find a value that does not exist in the sheet I get an error:
Run_time: "91"


h = InputBox("Type number of holes to find")

For X = 1 To h

np = InputBox("type the name of the hole:")

Cells.Find(What:=np, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate

N = ActiveCell
L = ActiveCell.Offset(0, 1)
S = ActiveCell.Offset(0, 2)

MsgBox ("Pozo:" & " " & N & " " & "Linea:" & " " & L & " " &
"Serial:" & " " & S)

End If

Next

How can I trap this run-time error?

Thanks



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 - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Error Trap Kirk P. Excel Programming 2 September 8th 05 09:51 PM
Error Trap TEB2 Excel Programming 2 March 15th 05 05:34 PM
error trap Rhonda[_3_] Excel Programming 2 October 22nd 03 07:07 PM


All times are GMT +1. The time now is 09:29 AM.

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

About Us

"It's about Microsoft Excel"