Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
AutoFilter method of Range Class Failed
I keep getting an error "AutoFilter method of Range Class Failed" when I run
this sub. I have data in B1:F232. Can someone help me, please ---------------------------------------------------------------------------- Sub test() Dim rng As Range Dim WS As Worksheet Dim WS2 As Worksheet Dim Str As String Dim LRow As Long Set WS = Sheets("Lod") Set WS2 = Sheets("Print282") LRow = LastRow(WS2) Str = "282" With WS.Columns("B:F") .AutoFilter Field:=1, Criteria1:=Str With WS.AutoFilter.Range On Error Resume Next Set rng = .Offset(0, 2).Resize(.Rows.Count - 1, 3) _ .SpecialCells(xlCellTypeVisible) On Error GoTo 0 If Not rng Is Nothing Then rng.Copy WS2.Range("B" & LRow + 1) End If End With End With WS.AutoFilterMode = False End Sub ---------------------------------------------------------------------------- Function LastRow(sh As Worksheet) On Error Resume Next LastRow = sh.Cells.Find(What:="*", _ after:=sh.Range("B1"), _ lookat:=xlPart, _ LookIn:=xlValues, _ searchorder:=xlByRows, _ searchdirection:=xlPrevious, _ MatchCase:=False).Row On Error GoTo 0 End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Autofill method of range class failed | Excel Discussion (Misc queries) | |||
Autofill method of range class failed | Excel Discussion (Misc queries) | |||
AutoFit method of Range class failed | Excel Programming | |||
VB Error: Paste Special method of range class failed | Excel Programming | |||
error 1004 Select method of Range class failed | Excel Programming |