I have a large excel VB macro which relys on error trapping to move on when it encounters an error.
I find that if I have more that one "on error goto [Line]" statement in a procedure, it only uses the first one. What do I have to do to switch to the next error handler?
Here is an example:
SKILL_CALLS:
Sheets("Skillset").Select
Range("A1").Select
For counter = 1 To 15
Cells.Find(What:="-", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
Selection.EntireRow.Insert
Selection.Offset(1, 0).Select
Next counter
Range("A4").Select
For counter = 1 To 15
On Error GoTo LAST_SORT
Range(ActiveCell, ActiveCell.CurrentRegion).Select
Selection.Sort Key1:=Range("A3"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Next counter
LAST_SORT:
Range("A3").Select
For counter = 1 To 15
On Error GoTo ENDOF
If ActiveCell = "Bookings_sk" Then Selection.Offset(1, 0).Select Else GoSub BOOKINGS_IN
If ActiveCell = "Campaign_sk" Then Selection.Offset(1, 0).Select Else GoSub CAMPAIGN_IN
If ActiveCell = "General_sk" Then Selection.Offset(1, 0).Select Else GoSub GENERAL_IN
If ActiveCell = "Patonga_sk" Then Selection.Offset(1, 0).Select Else GoSub PATONGA_IN
If ActiveCell = "Planning_sk" Then Selection.Offset(1, 0).Select Else GoSub PLANNING_IN
If ActiveCell = "Rates_sk" Then Selection.Offset(1, 0).Select Else GoSub RATES_IN
If ActiveCell = "VIP_sk" Then Selection.Offset(1, 0).Select Else GoSub VIP_IN
If ActiveCell = "Water_Sewer_sk" Then Selection.Offset(1, 0).Select Else GoSub WATER_SEWER_IN
Selection.End(xlDown).Select
Selection.Offset(1, 0).Select
Next counter
BOOKINGS_IN:
Selection.EntireRow.Insert
ActiveCell.FormulaR1C1 = "Bookings_sk"
Selection.Offset(1, 0).Select
Return
CAMPAIGN_IN:
Selection.EntireRow.Insert
ActiveCell.FormulaR1C1 = "Campaign_sk"
Selection.Offset(1, 0).Select
Return
GENERAL_IN:
Selection.EntireRow.Insert
ActiveCell.FormulaR1C1 = "General_sk"
Selection.Offset(1, 0).Select
Return
PATONGA_IN:
Selection.EntireRow.Insert
ActiveCell.FormulaR1C1 = "Patonga_sk"
Selection.Offset(1, 0).Select
Return
PLANNING_IN:
Selection.EntireRow.Insert
ActiveCell.FormulaR1C1 = "Planning_sk"
Selection.Offset(1, 0).Select
Return
RATES_IN:
Selection.EntireRow.Insert
ActiveCell.FormulaR1C1 = "Rates_sk"
Selection.Offset(1, 0).Select
Return
VIP_IN:
Selection.EntireRow.Insert
ActiveCell.FormulaR1C1 = "VIP_sk"
Selection.Offset(1, 0).Select
Return
WATER_SEWER_IN:
Selection.EntireRow.Insert
ActiveCell.FormulaR1C1 = "Water_sewer_sk"
Selection.Offset(1, 0).Select
Return
ENDOF:
Range("A1").Select
'This locates the first agent by finding GENERAL_SK.
On Error GoTo CALL_LAST_TAB
Cells.Find(What:="General_sk", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Replace What:="General_sk", Replacement:="General Skill", _
LookAt:=xlPart, SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat _
:=False, ReplaceFormat:=False
Range(ActiveCell, ActiveCell.CurrentRegion).Select