Turn the Autofilter Off

nniedzielski

Well-known Member
Joined
Jan 8, 2016
Messages
598
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

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
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,215,212
Messages
6,123,649
Members
449,111
Latest member
ghennedy

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