W
Wesslan
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?
'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?