Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selection.AutoFilter Issue
I have the same code for 5 different reports. The only difference in code is
the criteria filtered and removed. All reports filter and remove the desired data just fine except for one. The code is below and it is the same each reports with the exception of the worksheets it is deleting and Criteria1 for each sheet. NOTE: The BCP E&M code below filters correctly but not the others...and they are the same code! Any help would be greatly appreciated. Dim myLastRow As Long Dim myLastColumn As Long Dim myLastCell As String Dim myRange As String Dim Newbook As String Dim fName As Variant Dim MyDate As Date Application.ScreenUpdating = False MyDate = Date Application.DisplayAlerts = False Worksheets(Array("SUMMARY", "HCFG", "TOGCSG", "WBR")).Select ActiveWindow.SelectedSheets.Delete Sheets("New Vendors").Select Worksheets("New Vendors").AutoFilterMode = False Selection.AutoFilter Field:=4, _ Criteria1:="<WHOLESALE BANKING" myLastRow = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row myLastColumn = Cells.Find("*", [A1], , , xlByColumns, xlPrevious).Column myLastCell = Cells(myLastRow, myLastColumn).Address If myLastCell = "" Or myLastRow = "1" Then Selection.AutoFilter Selection.AutoFilter Range("A2").Select Else myRange = "D2:" & "D" & myLastRow Range(myRange).Delete Selection.AutoFilter Selection.AutoFilter Range("A2").Select End If Sheets("Pending").Select Worksheets("Pending").AutoFilterMode = False Selection.AutoFilter Field:=4, _ Criteria1:="<WHOLESALE BANKING" myLastRow = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row myLastColumn = Cells.Find("*", [A1], , , xlByColumns, xlPrevious).Column myLastCell = Cells(myLastRow, myLastColumn).Address If myLastCell = "" Or myLastRow = "1" Then Selection.AutoFilter Selection.AutoFilter Range("A2").Select Else myRange = "D2:" & "D" & myLastRow Range(myRange).Delete Selection.AutoFilter Selection.AutoFilter Range("A2").Select End If Sheets("BCP").Select Worksheets("BCP").AutoFilterMode = False Selection.AutoFilter Field:=4, _ Criteria1:="<WHOLESALE BANKING" myLastRow = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row myLastColumn = Cells.Find("*", [A1], , , xlByColumns, xlPrevious).Column myLastCell = Cells(myLastRow, myLastColumn).Address If myLastCell = "" Or myLastRow = "1" Then Selection.AutoFilter Selection.AutoFilter Range("A2").Select Else myRange = "D2:" & "D" & myLastRow Range(myRange).Delete Selection.AutoFilter Selection.AutoFilter Range("A2").Select End If Sheets("BCP E&M").Select Worksheets("BCP E&M").AutoFilterMode = False Selection.AutoFilter Field:=4, _ Criteria1:="<WHOLESALE BANKING" myLastRow = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row myLastColumn = Cells.Find("*", [A1], , , xlByColumns, xlPrevious).Column myLastCell = Cells(myLastRow, myLastColumn).Address If myLastCell = "" Or myLastRow = "1" Then Selection.AutoFilter Selection.AutoFilter Range("A2").Select Else myRange = "D2:" & "D" & myLastRow Range(myRange).Delete Selection.AutoFilter Selection.AutoFilter Range("A2").Select End If |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selection.AutoFilter Issue
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
array-to-row autofilter issue | Excel Programming | |||
AutoFilter Issue | Excel Programming | |||
Issue with Autofilter and Pictures | Excel Discussion (Misc queries) | |||
Autofilter Issue | Excel Worksheet Functions | |||
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. | Excel Programming |