disabling autofilter mode after filter data based on cell value

MKLAQ

Active Member
Joined
Jan 30, 2021
Messages
387
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
 
Ok, 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, Target.Value, , , 0
      Else
         .AutoFilter i, , , , 0
      End If
   Next i
   End With
 End If
End If
End Sub
 
Upvote 0
Solution

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
great ! but I have a question in your code used loop , is it necessary is not it possible without loop ?
 
Upvote 0
sorry I'm asking too much but what means comma before 0 sometimes you use 3 commas and 4 commas what means that
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,524
Messages
6,114,117
Members
448,549
Latest member
brianhfield

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