Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Selection.AutoFilter Issue


If desired, send your file to my address below. I will only look if:
1. You send a copy of this message on an inserted sheet
2. You give me the newsgroup and the subject line
3. You send a clear explanation of what you want
4. You send before/after examples and expected results.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"crmulle" wrote in message
...
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
array-to-row autofilter issue Tekito Excel Programming 3 September 15th 09 03:17 PM
AutoFilter Issue R NG[_2_] Excel Programming 2 September 4th 09 03:12 PM
Issue with Autofilter and Pictures J_Mori Excel Discussion (Misc queries) 3 April 20th 07 09:22 PM
Autofilter Issue PWS Excel Worksheet Functions 3 April 18th 07 04:23 PM
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. jonH Excel Programming 3 June 7th 04 09:13 PM


All times are GMT +1. The time now is 02:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"