Turn the Autofilter Off

nniedzielski

Well-known Member
Joined
Jan 8, 2016
Messages
590
Office Version
  1. 2019
Platform
  1. Windows
I am running this code, but when its done the worksheet yc is still left filtered, and i have to turn it off, im currently running this:

VBA Code:
    With yc
        .Range("A1:F1").AutoFilter Field:=6, Criteria1:="Red Tag"
        .AutoFilter.Range.Copy Sheets("Red Tag").Range("A1")
    End With
    
    With Sheets("Red Tag").UsedRange.Borders
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    Sheets("Red Tag").UsedRange.EntireColumn.AutoFit

i tried to just add an autofilter by doing:

Code:
.autofilter

but that didnt work
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
VBA Code:
Dim yc As Worksheet
Set yc = Sheets("Yard")

Code:
    With yc
        .Range("A1:F1").AutoFilter Field:=6, Criteria1:="Red Tag"
        .AutoFilter.Range.Copy Sheets("Red Tag").Range("A1")
    End With
    
    With Sheets("Red Tag").UsedRange.Borders
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    Sheets("Red Tag").UsedRange.EntireColumn.AutoFit
 
Upvote 0
Try this:
As a example:
VBA Code:
Sub Filter_Me()
With Sheets(1)
.Range("A1:F1").AutoFilter Field:=6, Criteria1:="Red Tag"
        .AutoFilter.Range.Copy Sheets("Red Tag").Range("A1")
        .Range("A1:F1").AutoFilter
End With
End Sub
 
Upvote 0
for future reference, you can also use
VBA Code:
With yc
        .Range("A1:F1").AutoFilter Field:=6, Criteria1:="Red Tag"
        .AutoFilter.Range.Copy Sheets("Red Tag").Range("A1")
        .autofilter.showalldata
    End With
 
Upvote 0
for future reference, you can also use
VBA Code:
With yc
        .Range("A1:F1").AutoFilter Field:=6, Criteria1:="Red Tag"
        .AutoFilter.Range.Copy Sheets("Red Tag").Range("A1")
        .autofilter.showalldata
    End With
But doing it your way you still have all those Filter down arrow icons showing.
My way eliminates all that.
 
Upvote 0
Agreed, but it depends on the needs of the OP... :) ...which is why I posted the option !
 
Upvote 0

Forum statistics

Threads
1,214,416
Messages
6,119,384
Members
448,889
Latest member
TS_711

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