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: 395
Default OnError not trapping subsequent errors?

I am working with an org chart "tree" in table form to find the reporting
heirachy. I start with the employee name, look it up on another table, and
find that person's reporting manager. Then I look up that manager as an
employee to find their manager, and so on.

Eventually each tree hits an error when I get to the top of the tree,
because it can't find a matching manager name. So, I use onError to escape
the loop and present the data onscreen for review.

This works fine the first time, but the code stops with an error on the
second 'original' employee- it is like the code forgot about the OnError
statement. I even added a goto 0 statement in case it needs some type of
'reset', but that didn't help.

Any ideas?
Thanks,
Keith

sorry for the linewrap...

Sub CheckHRSTCNames()

Dim OutArr(1 To 10)
SHRRowCnt = lastRow(Sheets(7))
SourceHRIDArr = Sheets(7).Range("A1:A" & SHRRowCnt)
SourceHRMgrArr = Sheets(7).Range("B1:B" & SHRRowCnt)

For tempRow = 2 To lastRow(Sheets(6))

Erase OutArr

tID = Sheets(6).Range("A" & tempRow).Value
matchRow = Application.Match(CStr(tID), SourceHRIDArr, False)
'Debug.Print tID

On Error GoTo ShowResults
For p = 1 To 10
OutArr(p) = Sheets(7).Range("AD" & matchRow).Value '<--errors here
on second loop, when p gets to about 7 or 8 depending on the employee
matchRow = Application.Match(OutArr(p), SourceHRMgrArr, False)
Next

ShowResults:
MsgBox OutArr(1) & ", " & OutArr(2) & ", " & OutArr(3) & ", " &
OutArr(4) & ", " & OutArr(5) & ", " & _
OutArr(6) & ", " & OutArr(7) & ", " & OutArr(8) & ", " &
OutArr(9) & ", " & OutArr(10)
On Error GoTo 0

Next

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
Trapping errors. Graeme[_2_] Excel Programming 1 November 14th 08 12:39 PM
Trapping errors ssemtaf Excel Programming 2 October 27th 08 07:56 PM
GetOpenFilename - Trapping Errors Tim Childs Excel Programming 5 April 9th 06 03:58 PM
Trapping Workbook OPEN errors sclark Excel Programming 1 January 18th 04 11:12 PM
annoying bell when trapping errors Mika Excel Programming 0 November 7th 03 10:41 AM


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