disabling autofilter mode after filter data based on cell value

MKLAQ

Board Regular
Joined
Jan 30, 2021
Messages
111
Office Version
  1. 2016
Platform
  1. Windows
hello
I have this code but I would make autofilter mode = false after filter data I tried with this code but it doesn't so far
any idea to do that ,please ?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$1" Then
 If Range("B2") = "All" Then

  Range("A3:E3").AutoFilter
 Else
  Range("A3:E3").AutoFilter Field:=2, Criteria1:=Range("B1")
  'ActiveSheet.AutoFilterMode = False
 End If
End If
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,969
Office Version
  1. 365
Platform
  1. Windows
What you are trying to do makes no sense. Why filter the table & then immediately remove the filter?
 

MKLAQ

Board Regular
Joined
Jan 30, 2021
Messages
111
Office Version
  1. 2016
Platform
  1. Windows
May be my question is not clear what I want remove arrow relating autofilter
should autofiltemode =false after filter data but I no know where put it this
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,969
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Autofilter mode does not remove the dropdowns it removes the entire filter.
 

MKLAQ

Board Regular
Joined
Jan 30, 2021
Messages
111
Office Version
  1. 2016
Platform
  1. Windows
I would remove arrows in topic headers from a3:e3 after filter data based on dropdown
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,969
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

In that case try
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long
If Target.Address = "$B$1" Then
 If Range("B2") = "All" Then

  Range("A3:E3").AutoFilter
 Else
   With Range("A3:e3")
   For i = 1 To 5
      If i = 2 Then
         .AutoFilter i, Range("B2").Value, , , 0
      Else
         .AutoFilter i, , , , 0
      End If
   Next i
   End With
 End If
End If
End Sub
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,969
Office Version
  1. 365
Platform
  1. Windows
What do you mean it's gone?
 

MKLAQ

Board Regular
Joined
Jan 30, 2021
Messages
111
Office Version
  1. 2016
Platform
  1. Windows
it hides the rows which contain data , it does not show any thing when select from dropdown
 

Watch MrExcel Video

Forum statistics

Threads
1,130,321
Messages
5,641,513
Members
417,213
Latest member
wikk

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
Top