johnny_raman
New Member
- Joined
- Mar 26, 2014
- Messages
- 22
Hi,
Thanks for your time.
I am trying to run the below macro code and have no issues till the last line (Macro 2) where all i want is to delete visible rows (special cells).
The last step either runs for 10-15 mins to complete the action or throws out at error (Runtime error 1004).
Also if by any chance can i change the Range from 20000 to selection until last cell pasted in the workbook.
Thanks in advance.
Thanks for your time.
I am trying to run the below macro code and have no issues till the last line (Macro 2) where all i want is to delete visible rows (special cells).
The last step either runs for 10-15 mins to complete the action or throws out at error (Runtime error 1004).
Also if by any chance can i change the Range from 20000 to selection until last cell pasted in the workbook.
Thanks in advance.
Code:
Sub Macro2()
Dim lRow As Long
Range("A1:XFD20000").Select
Selection.AutoFilter
Range("O1").Select
ActiveSheet.Range("$1:$20000").AutoFilter Field:=15, Criteria1:="B737"
Selection.End(xlToRight).Select
Range("AD1").Select
ActiveSheet.Range("$1:$20000").AutoFilter Field:=30, Criteria1:="<>"
With ActiveSheet
lRow = .Cells(.Rows.Count, 15).End(xlUp).Row
If lRow = 1 Then Exit Sub
.Cells(1, 15).Offset(1, 0).Resize(lRow - 1).SpecialCells(xlCellTypeVisible).Value = "B737 BBJ"
End With
Range("A1:XFD20000").Select
Selection.AutoFilter
Range("O1").Select
ActiveSheet.Range("$1:$20000").AutoFilter Field:=15, Criteria1:="Non Aircraft Specific"
Selection.End(xlToRight).Select
Range("B1").Select
ActiveSheet.Range("$1:$20000").AutoFilter Field:=2, Criteria1:=Array("Amsterdam", "Dubai", "Shanghai", "UK Burgess Hill"), Operator:=xlFilterValues
Selection.End(xlToRight).Select
With ActiveSheet
lRow = .Cells(.Rows.Count, 15).End(xlUp).Row
If lRow = 1 Then Exit Sub
.Cells(1, 15).Offset(1, 0).Resize(lRow - 1).SpecialCells(xlCellTypeVisible).Value = "Others"
End With
Range("A1:XFD20000").Select
Selection.AutoFilter
Range("B1").Select
ActiveSheet.Range("$1:$20000").AutoFilter Field:=2, Criteria1:=Array("Dallas", "Bombardier - Montreal", "NETC", "BBD Dallas", "Embraer CAE Brazil", "Embraer CAE Dallas"), Operator:=xlFilterValues
Selection.End(xlToRight).Select
Range("AE1").Select
ActiveSheet.Range("$1:$20000").AutoFilter Field:=31, Criteria1:=""
ActiveSheet.Range("$1:$20000" & Lines).Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End Sub
Last edited by a moderator: