VBA Autofilter error

Taff

Board Regular
Joined
Mar 31, 2004
Messages
151
Office Version
  1. 365
Platform
  1. Windows
  2. Web
Can somebody have a look at the below VBA for me and advise why i am getting an error Message: autofilter method of range class failed.

I am trying to filter a worksheet "match summaries" with the text "Back O2.5" in column CE, by the text "Back O2.5"
then copying the filtered selection into the worksheet "back O2.5"

VBA Code:
Sub Filterselections()

    Dim wsA As Worksheet: Set wsA = Sheets("Match Summaries") ' base data held here
     Dim wsB As Worksheet: Set wsB = Sheets("Back O2.5")

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

With wsA.[a4:ce215].CurrentRegion

        .AutoFilter 83, "=Back O2.5" 'filter rows with values O2.5 in CE
        .Offset(1).EntireRow.Copy wsB.Range("A" & Rows.Count).End(3)(2) 'copy info to worksheet called Back O2.5
        .AutoFilter
   
End With
          
Application.CutCopyMode = False
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True

End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Taff,

If there are any blank columns between "a" and "ce", CurrentRegion will not include column ce and AutoFilter will prompt an error.
Perhaps eliminate CurrentRegion.

Cheers,

Tony
 
Last edited:
Upvote 0
Solution

Forum statistics

Threads
1,214,958
Messages
6,122,475
Members
449,087
Latest member
RExcelSearch

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top