I have an extensive bit of code that is processing a report of raw data into usable worksheets. I'm getting the 1004 error toward the end. The code is filtering data on Sheet 2, copying it, pasting it to a new sheet tab, and is then going back and deleting out the filtered data, and then repeats for several more tabs. It's running fine for the first 3-4 filter criteria, but then failing on the last one. I'm lost as it's the same code it's already run without incident.
I've tried rewording how I define my range initially. No luck. I've tried changing up the order of the code, still no luck.
DIM rng As Range (defined in Private Sub CommandButton1_Click())
Module 1 Code
.
.
.
Selection.End(xlDown).Select 'where I define rng
ActiveCell.Offset(0, 12).Select
Set rng = ActiveCell
Range("A2", rng).Select
.
.
.
'Creates GroupB tab WORKS FINE
ActiveSheet.Range("$A$1:$N$192").AutoFilter Field:=5, Criteria1:="GroupB"
Selection.Copy
Sheets("Sheet2").Select
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
Sheets("Sheet2").Select
Range(Range("A2"), rng).SpecialCells(xlCellTypeVisible).EntireRow.Delete
'Creates GroupC tab WORKS FINE
ActiveSheet.Range("$A$1:$N$192").AutoFilter Field:=5, Criteria1:="GroupC"
Range("A1", rng).Select
Selection.Copy
Sheets("Sheet3").Select
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
Sheets("Sheet2").Select
Range(Range("A2"), rng).SpecialCells(xlCellTypeVisible).EntireRow.Delete
'Creates GroupD tab WORKS FINE
ActiveSheet.Range("$A$1:$N$192").AutoFilter Field:=5, Criteria1:="GroupD"
Range("A1", rng).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet4").Select
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
Sheets("Sheet2").Select
Range(Range("A2"), rng).SpecialCells(xlCellTypeVisible).EntireRow.Delete
'Creates GroupE tab
ActiveSheet.Range("$A$1:$N$192").AutoFilter Field:=5, Criteria1:="GroupE"
Range("A1", rng).Select *Fails HERE with the run time error 1004 vba method range object _global failed Error
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet5").Select
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
Sheets("Sheet2").Select
Range(Range("A2"), rng).SpecialCells(xlCellTypeVisible).EntireRow.Delete
Please I don't know why it works fine for GroupB-D, but not E, it's the SAME code.