Error Handling: GoTo Err1 Help.

Wamhoi

New Member
Joined
Mar 4, 2011
Messages
48
I can't get my error handeling to work. It breaks on the following line. Any Ideas?

On Error GoTo Err1 ' Breaks here "Compile error: Label not Defined"

Range("A10").Select
Range("Master").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range("Group"), CopyToRange:=Range("A1:K1"), Unique:=False

On Error GoTo 0

End Sub

Err1:
Sheets("NYFilter").Rows("1:1").ClearContents
Sheets("Prior-NYFilter").Rows("1:1").Copy
Sheets("NYFilter").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

Resume
End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Try

Rich (BB code):
On Error GoTo Err1 ' Breaks here "Compile error: Label not Defined"
 
Range("A10").Select
Range("Master").AdvancedFilter Action:=xlFilterCopy,  CriteriaRange:=Range("Group"), CopyToRange:=Range("A1:K1"), Unique:=False
 
On Error GoTo 0
 
Exit Sub
 
Err1:
    Sheets("NYFilter").Rows("1:1").ClearContents
    Sheets("Prior-NYFilter").Rows("1:1").Copy
    Sheets("NYFilter").PasteSpecial Paste:=xlPasteValues,   Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    
Resume
End Sub
 
Upvote 0
Thank you so much! I had a follow up question. Using the same code, if Err1 doesn't fix the problem, I believe it begins to loop endlessly. Is there anyway to avoid that?
 
Upvote 0
Maybe like this

Code:
On Error GoTo Err1 ' Breaks here "Compile error: Label not Defined"
 
Range("A10").Select
Range("Master").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range("Group"), CopyToRange:=Range("A1:K1"), Unique:=False
 
On Error GoTo 0
 
Exit Sub
 
Err1:
    If ErrorCount > 1 Then Exit Sub
    ErrorCount = ErrorCount + 1
    Sheets("NYFilter").Rows("1:1").ClearContents
    Sheets("Prior-NYFilter").Rows("1:1").Copy
    Sheets("NYFilter").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    
Resume
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,277
Messages
6,171,156
Members
452,385
Latest member
Dottj

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top