LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Error 91 on Second Error

Hi,

Not very good with error trapping and struggling with a macro that basically
seach tries to find a match within a series of cell's (using selection .find)
all works fine if there is a match, and the first time there is not a match.
But if there is a second no match i get an error 91. Do I need to clear/reset
the error after each occurence ? I have tried but with no success :

Please see relevant section of code :


'1st Search
searchval = 1
pasterow = 2
On Error GoTo line5
Sheets(2).Select
Columns("A:E").Select
Selection.Find(What:=fap, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate

ddrow = ActiveCell.Row
ddcol = ActiveCell.Column

For ddrow = ddrow To 25
Sheets(2).Select
If Cells(ddrow, ddcol).Value fap Then
ddrow = 25
End If

If Cells(ddrow, ddcol).Value = fap Then
If ddcol = 1 Then
role = Cells(ddrow, 1).Value
rolecount = Cells(ddrow, 2).Value
End If

If ddcol = 4 Then
role = Cells(ddrow, 4).Value
rolecount = Cells(ddrow, 5).Value
End If

Sheets(sh).Select
Cells(pasterow, 1).Value = role
Cells(pasterow, 2).Value = rolecount
pasterow = pasterow + 1

End If
Next ddrow




'2nd search
line3:

searchval = 2
pasterow = 2
On Err GoTo line5
Sheets(3).Select
Columns("A:E").Select
Selection.Find(What:=fap, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate

eerow = ActiveCell.Row
ddcol = ActiveCell.Column

For eerow = eerow To 25
Sheets(3).Select
If Cells(eerow, ddcol).Value fap Then
eerow = 25
End If

If Cells(eerow, ddcol).Value = fap Then
If ddcol = 1 Then
role = Cells(eerow, 1).Value
rolecount = Cells(eerow, 2).Value
End If

If ddcol = 4 Then
role = Cells(eerow, 4).Value
rolecount = Cells(eerow, 5).Value
End If

Sheets(sh).Select
Cells(pasterow, 3).Value = role
Cells(pasterow, 4).Value = rolecount
pasterow = pasterow + 1

End If
Next eerow








line4:

selrow = selrow + 1
' Next b


Next a


line5:
If searchval = 1 Then
GoTo line3
Err.Clear
error.Clear

End If

If searchval = 2 Then
GoTo line4
Err.Clear
error.Clear
End If






line1:








End Sub

 
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: "Excel encountered an error and had to remove some formatti Carl Excel Discussion (Misc queries) 0 September 18th 06 06:39 PM
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
Automation Error, Unknown Error. Error value - 440 Neo[_2_] Excel Programming 0 May 29th 04 05:26 AM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM


All times are GMT +1. The time now is 12:10 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"