LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default AutoFilter fails

This walks through the code and displays the filtered items, then jumps back
to line one of the code, retraces the original steps and when it hits the
autofilter again it give me an error that AutoFilter failed. I can't figure
out why it won't go to the next step and copy what it had filtered
originally. Can somebody explain what might be missing or what should be
omitted from this code? Appreciate the help.

Private Sub ListBox1_Click()
Dim ws As Worksheet
Dim rng As Range
Dim rng2 As Range
Dim lr4, lc4, mCnt, cnt As Long
lr = Sheets("Sheet1").Cells(Rows.Count, 2).End(xlUp).Row
lr4 = Sheets("Sheet2").Cells(Rows.Count, 2).End(xlUp).Row
lc4 = Sheets("Sheet2").UsedRange.Columns.Count + 1
Set ws = Worksheets("Sheet1")
Set rng = ws.Range("B26:AD" & lr)
myVar4 = UserForm1.ListBox1.Value
Sheets("Sheet1").Range("A25") = ListBox1.Value
For i = 0 To UserForm1.ListBox1.ListCount - 1
If UserForm1.ListBox1.Selected(i) Then
'With Application
'.ScreenUpdating = False
'.EnableEvents = False
'End With
ws.AutoFilterMode = False
cRng = Sheets("Sheet1").Range("A25").Value
rng.AutoFilter Field:=1, Criteria1:=cRng, VisibleDropDown:=False
ws.AutoFilter.Range.Copy
Sheets("Sheet2").Range("B" & lr + 1).PasteSpecial Paste:=xlValues
ws.AutoFilterMode = False
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End If
Next
 
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
excel 2007 autofilter change to 2003 autofilter functionality? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 10:05 PM
2007 excel autofilter back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 3 April 19th 10 08:11 PM
2007 excel autofilter change back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 05:53 PM
autofilter fails, not because of blank row John Keith Excel Discussion (Misc queries) 5 August 20th 09 03:36 PM
2007 Autofilter worse than 2003 Autofilter jsky Excel Discussion (Misc queries) 9 October 31st 07 12:14 AM


All times are GMT +1. The time now is 08:31 PM.

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"