Think Macro gets jammed with my On Error GoTo

Anthony2687

New Member
Joined
Jan 5, 2012
Messages
37
I am running into the issue when it has to switch from the GoTo function to Create it causes an error. I can just ignore the error and just continue, but I would like for this to be seemless. Does anyone see my error or have advice?




Do</SPAN>
Sheets("Sheet2").Range("$A$1:$K$299").AutoFilter Field:=4, Criteria1:=Range("A301").Value, Operator:=xlAnd</SPAN>
Range("A2:K300").Select</SPAN>
Application.CutCopyMode = False</SPAN>
Selection.Copy</SPAN>
SheetExists = False</SPAN>
On Error GoTo Create</SPAN>
SheetExists = Sheets(Sheets("Sheet2").Range("A301").Text).Select <> ""</SPAN>
Cells(Rows.Count, "A").End(xlUp)(2).Select</SPAN>
ActiveSheet.Paste</SPAN>
Create:</SPAN>
If Not SheetExists Then</SPAN>
Sheets.Add After:=Sheets(Sheets.Count)</SPAN>
Cells(Rows.Count, "A").End(xlUp)(2).Select</SPAN>
ActiveSheet.Paste</SPAN>
ActiveSheet.Name = Range("D2").Value</SPAN>
End If</SPAN>
Sheets("Sheet2").Select</SPAN>
Rows("301:301").Select</SPAN>
Application.CutCopyMode = False</SPAN>
Selection.Delete</SPAN>
Loop Until IsEmpty(ActiveCell)






</SPAN>

<TBODY>
</TBODY><COLGROUP><COL></COLGROUP>
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Maybe I said it wrong, but I have On Error GoTo, I think the switching back and forth between those 2 functions causes a small error.
 
Upvote 0
In walking through step by step with the code, if the she name is not there and it has to skip and go down to create when it starts over I get "Script out of Range error" on it get back to the SheetExists line. Do you have any Idea why this would be?
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,479
Members
448,967
Latest member
visheshkotha

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