Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Problem with Error handling in loop (with find)

I have created the following peace of code:

'Finds company within the peer group
On Error Goto CompanyNotPartofPeerGroup
Cells.Find(What:=ExcludedCompany, After:=Cells(1, 1),
LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate


'Eliminates the analyzed company if it is truly part of the peer
group
ActiveCell.FormulaR1C1 = "=ROW()"
temp = ActiveCell.Value
Rows(temp).Delete shift:=xlUp


CompanyNotPartofPeerGroup:
On Error Goto 0


The problem is that this works the first time the code is run (so if
the company is not part of the peer group a row is not deleted, but
rather it goes to CompanyNotPartofPeerGroup). But the second time the
code is run (part of the loop) and if the company analyzed is not
part
of the peer group, then the Error Handling breaks down and instead of
going to CompanyNotPartofPeerGroup it handles the procedure as if I
had written "On Error Resume Next"...


Any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Problem with Error handling in loop (with find)

See response in .excel group.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Wesslan" wrote in message
...
I have created the following peace of code:

'Finds company within the peer group
On Error Goto CompanyNotPartofPeerGroup
Cells.Find(What:=ExcludedCompany, After:=Cells(1, 1),
LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate


'Eliminates the analyzed company if it is truly part of the peer
group
ActiveCell.FormulaR1C1 = "=ROW()"
temp = ActiveCell.Value
Rows(temp).Delete shift:=xlUp


CompanyNotPartofPeerGroup:
On Error Goto 0


The problem is that this works the first time the code is run (so if
the company is not part of the peer group a row is not deleted, but
rather it goes to CompanyNotPartofPeerGroup). But the second time the
code is run (part of the loop) and if the company analyzed is not
part
of the peer group, then the Error Handling breaks down and instead of
going to CompanyNotPartofPeerGroup it handles the procedure as if I
had written "On Error Resume Next"...


Any ideas?



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 - Infinite loop coder_arun[_7_] Excel Programming 1 August 4th 06 09:51 AM
Error Handling - Infinite loop coder_arun[_6_] Excel Programming 0 August 3rd 06 01:38 PM
help with 'Find' error handling please michael.beckinsale Excel Programming 2 July 28th 06 04:08 PM
Newbie Q: Error handling procedures in a loop KR Excel Programming 2 March 4th 05 05:51 PM
Error Handling Problem Minitman[_4_] Excel Programming 3 November 15th 04 06:52 AM


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

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"