VBA Autofilter

kapi98

New Member
Joined
Jun 15, 2021
Messages
28
Office Version
  1. 365
Platform
  1. Windows
Hi there,

I've been trying to merge these two codes in hundreds different ways but I didn't work out.

Could you please advice if there's a way to filter my data, and then, hide the filter arrows?

VBA Code:
ActiveSheet.Range("$L$5:$Q$52").AutoFilter Field:=1, Criteria1:=4, _
    Operator:=11, Criteria2:=0, SubField:=0

VBA Code:
Dim c As Range
Dim i As Integer
Dim rng As Range
Set rng = ActiveSheet.AutoFilter.Range.Rows(1)
i = 1
Application.ScreenUpdating = False
For Each c In rng.Cells
  c.AutoFilter Field:=i, _
      Visibledropdown:=False
  i = i + 1
Next
Application.ScreenUpdating = True

Thanks
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Well this worked. But removing the arrows cleared the filter

VBA Code:
Sub Macro1()

Dim c As Range
Dim i As Integer
Dim rng As Range

ActiveSheet.Range("$L$5:$N$14").AutoFilter Field:=1, Criteria1:=4, _
    Operator:=11, Criteria2:=0, SubField:=0
    

Set rng = Range("$L$5:$N$14")
i = 1
Application.ScreenUpdating = False
For Each c In rng.Cells
  c.AutoFilter Field:=i, _
      Visibledropdown:=False
  i = i + 1
Next
Application.ScreenUpdating = True

End Sub

Turning the data into a table and adding a silcer may be an option.

1625622584502.png
 
Upvote 0
Unfortunately, I can't turn this into a table due to repetitive headings.
 
Upvote 0
VBA to hide the rows then I suppose. Everything else i'm seeing is about hiding the non filtered arrows.
 
Upvote 0
Exactly, this code only hides the filtrated arrows

VBA Code:
ActiveSheet.Range("$L$5:$Q$52").AutoFilter Field:=1, Criteria1:=4, _
    Operator:=11, Criteria2:=0, SubField:=0, Visibledropdown:=False
Application.ScreenUpdating = True
 
Upvote 0
Think I get it now, had similar working with 1 criteria.

VBA Code:
Sub Macro1()

Dim c As Range
Dim i As Integer
Dim rng As Range

Set rng = Range("$L$5:$Q$5")
i = 1
For Each c In rng.Cells
  c.AutoFilter Field:=i, Criteria1:=4, _
    Operator:=11, Criteria2:=0, SubField:=0
  i = i + 1
Next
Application.ScreenUpdating = True

End Sub
 
Upvote 0
I've already tried this combination but the filter returns no results, even though it should find two rows.
 
Upvote 0

Forum statistics

Threads
1,215,772
Messages
6,126,803
Members
449,337
Latest member
BBV123

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