HomePro
Board Regular
- Joined
- Aug 3, 2021
- Messages
- 157
- Office Version
- 365
- 2021
- 2019
- 2016
- 2013
- 2011
- 2010
- 2007
- 2003 or older
- Prefer Not To Say
- Platform
- Windows
- MacOS
- Mobile
- Web
I am using VBA code to run a filter, copy the results to a new sheet and then delete the results from the original sheet but not the header.
Then I am running a different filter and repeating that. But when I try to delete those results I get the error
Application-defined or object-defined error. I do not know what this means or how to get around it. Can anyone help?
Then I am running a different filter and repeating that. But when I try to delete those results I get the error
Application-defined or object-defined error. I do not know what this means or how to get around it. Can anyone help?
VBA Code:
Sub WORKING()
'PARSE AGREEMENT TYPE
'GET LAST ROW
lR = Cells(Rows.Count, 1).End(xlUp).Row
Cells.Select
Selection.AutoFilter
ActiveSheet.Range("A1:L" & lR).AutoFilter field:=4, Criteria1:= _
"= AGREEMENT TYPE", Operator:= _
xlOr, Criteria2:="="
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets.Add(After:=Sheets(Sheets.Count)).Name = "Choose Agreement"
ActiveSheet.Paste
Sheets("DATA").Select
'DELETE FILTERD ROWS
ActiveSheet.AutoFilter.Range.Offset(1).Delete xlShiftUp
If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilterMode = False
'PARSE CALL BACKS BY CSR
'Kayla
'GET LAST ROW
lR = Cells(Rows.Count, 1).End(xlUp).Row
Cells.Select
Selection.AutoFilter
ActiveSheet.Range("A1:L" & lR).AutoFilter field:=2, Criteria1:= _
"Kayla", Operator:=xlOr, Criteria2:="="
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets.Add(After:=Sheets(Sheets.Count)).Name = "Kayla"
ActiveSheet.Paste
Sheets("DATA").Select
'DELETE FILTERD ROWS
MsgBox ActiveSheet.Name
Active.Sheet.AutoFilter.Range.Offset(1).Delete xlShiftUp
Selection.Offset(1).SpecialCells(xlCellTypeVisible).Delete Shift:=xlUp
If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilterMode = False
End Sub